all
I bet this is a frequently asked question. But each time it is raised with a different context. Here is my problem: I have a project in VS2012 Express. The project include few header files. It is meaningless to paste the whole project here, thus I just give a brief structure.
In header file Header.h, I have a parent class Sim which is defined as follows:
class Sim
{
protected:
// some member data
public:
Sim(int x, int y, A a);
vector<int> return_parameters(A a); // problems happen at this function
// class A is defined in another header file and properly included here
// function return_parameters has no definition, thus is an abstract function
}
Sim::Sim(int x, int y, A a)
{// some operations}
Then I have class Sim_son that public derived from Sim
class Sim_son: public Sim
{
private:
// some member data
public:
Sim_son(int x, int y, A a, int z);
vector<int> return_parameters(A a);
};
Sim_son::Sim_son(int x, int y, A a, int z): Sim(x,y, a)
{
// some operations
}
vector<int> Sim_son::return_parameters(A a)
{
return a.someData;
}
In main(), I code like this:
void main()
{
// some operations
Sim_son Obj_son(x, y, a, z);
Obj_son.return_parameters(a) //PROBLEM HAPPENS
}
The compiler gives a LNK2019 error which says unresolved external symbol Sim::return_parameters referenced in function Sim_son::Sim_son(void).
I commeted the line "Obj_son.return_parameters(a)", then the error disappears. So I guess this is the source of trouble.
Can anyone help me out of this? Many thanks in advance.
Best regards Long