Hi guys,
A few questions about constructors in c++. Given two classes, one called "UserInput" and the other "TextField"
the situation looks like this.
class UserInput{
public:
UserInput(int len):
str_len(len)
{
SDL_EnableUNICODE(SDL_ENABLE);
}
void handleInput(){
//do stuff here
}
private:
int str_len;
};
class TextField(){
public:
TextField():
user_input(20){
}
void handleInput(){
user_input.handleInput();
}
private:
UserInput user_input;
};
When later in the program, I instatiate an instance of TextField and call the function
text_field.handleInput();
the SDL_EnableUNICODE(SDL_ENABLE); is not active.
I suspect, if I make user_input a pointer, and allocate it onto the heap, this problem will go away but I don't understand the nuts and bolts.
Could someone explain to me why this is so?
Thanks,
Mike