hey I i am writing a Program in C++ and for some reason the compiler finds errors , and cant find my constructor: here is my class: (inside a h file)
class Adjutancy
{
private:
vector<Vehicale*,CompareCatId>* m_vehicalesVector;
map<const string,Base*>* m_baseMap;
map<const int,City*>* m_citiesMap;
vector<vector<Distance*>>* m_distancesMatrix;
public:
Adjutancy(vector<Vehicale*,CompareCatId>* vehicalesVector , map<const string,Base*>* baseMap , map<const int,City*>* citiesMap , vector<vector<Distance*>>* distancesMatrix);
};
and here is my constructor implementation inside a cpp file:
sorry about the length of it.
Adjutancy::Adjutancy(vector<Vehicale*,
CompareCatId>* vehicalesVector,map<const string,Base*>* baseMap,
map<const int,City*>* citiesMap,
vector<vector<Distance*>>* distancesMatrix):
m_vehicalesVector(vehicalesVector),
m_baseMap(baseMap),
m_citiesMap(citiesMap),
m_distancesMatrix(distancesMatrix)
{}
for some reason inside my main i cant use the constructor.
thanks in advance.
I suppose you mean this setup:
This is horrible code, and for several reasons:
std::vectors andstd::maps in your class: just store thevectors andmaps themselves, no pointers needed here. Alternatively, store a reference, but beware of the limitations (no un-initialized reference data members!).>>, put a space between the two, or some compilers will misinterpret it asoperator>>.usingstatements in your header, instead, use the full namespace prefix.I can’t say what’s wrong (everything looks correct at first glance) until you show me your
main(complete!) function and how you want to use your constructor.Better version:
Also remember: “vehicle” is the correct English spelling.