I suppose you mean this setup:
// file adjutancy.h
// ... includes for all classes used below
// forward declarations are OK for pointers and references
class Adjutancy
{
public:
Adjutancy(vector<Vehicale*,CompareCatId>* vehicalesVector , map<const string,Base*>* baseMap , map<const int,City*>* citiesMap , vector<vector<Distance*>>* distancesMatrix);
private:
vector<Vehicale*,CompareCatId>* m_vehicalesVector;
map<const string,Base*>* m_baseMap;
map<const int,City*>* m_citiesMap;
vector<vector<Distance*>>* m_distancesMatrix;
};
// file adjutancy.cpp
#include "adjutancy.h"
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)
{ }
This is horrible code, and for several reasons:
- You're storing a pointer to
std::vector
s and std::map
s in your class: just store the vector
s and map
s themselves, no pointers needed here. Alternatively, store a reference, but beware of the limitations (no un-initialized reference data members!).
- You should avoid template type lists with
>>
, put a space between the two, or some compilers will misinterpret it as operator>>
.
- Do not use
using
statements 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:
// file adjutancy.h
#include <map>
#include <string>
#include <vector>
class Adjutancy
{
public:
Adjutancy( std::vector<Vehicale*,CompareCatId> &vehicalesVector,
std::map<const std::string,Base*> &baseMap,
std::map<const int,City*> &citiesMap,
std::vector<std::vector<Distance*> > &distancesMatrix );
private:
std::vector<Vehicale*,CompareCatId> &m_vehicalesVector;
std::map<const std::string,Base*> &m_baseMap;
std::map<const int,City*> &m_citiesMap;
std::vector<std::vector<Distance*> > &m_distancesMatrix;
};
// file adjutancy.cpp
#include "adjutancy.h"
#include <map>
using std::map;
#include <string>
using std::string;
#include <vector>
using std::vector;
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 )
{ }
Also remember: "vehicle" is the correct English spelling.