class f {
public:
int *a;
f(int g) {
a = (int *) malloc (sizeof(int));
*a = g;
}
};
class h : public f {
int f;
h(int g) :
f(g) {} // the compiler interprets this line as an assignation to the local variable f
};
I can't construct a instance of f cause I can't find a way to call to the f's constructor. Is there a way to do that?
Thank you! (sorry for my bad english I am Belgian)
You shouldn't have a data member using the same identifier as the class. Usually naming conventions will make sure that doesn't happen (CamelCase for class identifiers, mixedCase or lowercase or lower_case_with_underscores for functions and data, for instance).