jeudi 21 septembre 2017

undefined reference when calling parameterized constructor

I have 2 classes Simulation and Station.

In the station.hh is the declaration as follows:

class Station{
private:
    Station(void);
    Station(std::string);
    ~Station(void);
    ...
public:
    ...
};

and in the simulation.hh is the declaration for Simulation.

class Simulation{
    Simulation();
    Simulation(std::string, std::string);
    ~Simulation();
};

Now, on the Simulation constructor I call the parameterized constructor for Station as follows:

Simulation::Simulation(std::string route1_file, std::string route2_file){
    Station* s0 = new Station();
    Station* s1 = new Station("AZU");
}

The first creation of the object works fine. The second one gives me the following error: undefined reference to Station::Station(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)

Is this a linker issue? Has it occurred to anyone?

Aucun commentaire:

Enregistrer un commentaire