I want to use different WText instances in another function, but as I want to have just one control function, I'd like to pass them in there.
The code with current setup compiles but fails due to some memory fault which I don't understand.
class mode : public WApplication
{
//..
private:
//..
void someFunc();
void control(WText* texty);
WText* text;
WText* text2;
WText* text3;
//...etc
};
void mode::someFunc(){
control(text); //how to pass it?
//might pass text2 or text3 as well
}
void mode::control(WText* texty){
texty->setText("blabla");
//..
}
text member is a pointer to the object WText, The first thing you need to do is a create a new WText object:
void mode::someFunc() {
text = new WText();
control(text);
}
please remember about destroy text object after use.