In case you're curious as to why you got that error message . . . after the preprocessor processes your #includes, your source looks like this:
Code:
class Button {
public:
Button();
}
Button::Button(){
printf("cenas");
}
Have you ever seen this syntax before?
Code:
struct tag {
int data;
} var1, var2;
It lets you declare instances of a structure at the same time you declare what the structure looks like. (If you do this then you can even leave out the structure tag if you're not going to use it anywhere else.) Well, the same thing applies here. You basically said:
Code:
class Button {
public:
Button();
} Button::Button() {
std::cout << "cenas" << endl; // I changed this printf to cout since this is C++!
}
In other words, you declared a class Button, and at the same time, you said "use this as the 'type' of the thing that follows". The "thing that follows" happened to be a function definition, so in effect you used the Button class definition as the return type of the constructor. It's pretty much the same thing as
Code:
class Button {
public:
Button();
};
Button Button::Button() {
std::cout << "cenas" << endl;
}
which is why the compiler didn't like it.