I'm getting "undefined reference to BaseClass::constructor()" whenever I try to compile. These errors don't pop up in visual studio, and I was wondering if someone can help me?
E.g: undefined reference to `BaseClass::BaseClass(int, int)'
1 2 3 4 5 6 7 8 9 10 11
BaseClass.h
class BaseClass {
protected:
intconst a1;
int s1;
...
public:
BaseClass(int a, int s);
...
};
1 2 3 4 5
BaseClass.cpp
BaseClass::BaseClass(int a, int s) : a1(a) {
s1 = s;
}
Then in my derived class:
1 2 3 4 5 6 7 8 9 10
ChildClass1.h
class ChildClass1: public BaseClass {
private:
int abc1;
public:
ChildClass1(int a, int s);
void setSomething(string s);
...
};
1 2 3 4 5
ChildClass1.cpp
ChildClass1::ChildClass1(int a, int s) : BaseClass(a, s) {
setSomething("hello");
}
I'm getting this undefined reference error for all of my derived classes in regards to the constructor and member functions.