Getting undefined reference to base class

Hi

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:
	int const 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.

Is there something wrong that I don't see?
Last edited on
Found the reason. I had forgotten to add BaseClass.cpp to my makefile... Doh
Topic archived. No new replies allowed.