Polymorphism with header file

Hello...
I am doing background for my second game. There would be 4 types of buildings in background, but all of them will do the same, so I chose polymorphism to code that (because it would be easier to construct city by this). The problem is, that I get some errors then I try to write a function of inherited class in .cpp file. What I am doing wrong? How can I properly write function in .cpp file? :)

Header file code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Buildings 
{
public:
	virtual void create();
	virtual void add(vector2 position);
	virtual void move();
};

class a_buildings : public Buildings
{
public:
	void create();
	void add(vector2 position);
	void move();

private:
	Texture tex_a1, tex_a2;
	object a1, a2;
}


.cpp code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "background.h"


void a_buildings::create()
{
	tex_a1.loadFromFile("gdata/graphics/a1.png");
}

void a_buildings::add(vector2 position)
{

}

void a_buildings::move(float dt)
{

}


Errors I get:

error C2144: syntax error : 'void' should be preceded by ';'
error C2628: 'a_buildings' followed by 'void' is illegal (did you forget a ';'?)
error C2556: 'a_buildings Buildings::add(vector2)' : overloaded function differs only by return type from 'void Buildings::add(vector2)'
error C2371: 'Buildings::add' : redefinition; different basic types
You forgot the semicolon after the class definition (line 19).
Oh my God... Thank you... I cant believe I didn't noticed that... :/
Topic archived. No new replies allowed.