M
Markus Pitha
Hello,
I have a class "Menu". In this class I declare an object "Controller".
Now I have a problem:
Controller uses a ctor but I get the value I have to pass later in my
program.
The only way to solve this is to make a new instance of "Controller" and
use it dynamically, but how can I use it as static object?
class Menu {
private:
int knotenanzahl;
Controller *controller;
void setMatrix();
public:
Menu();
virtual ~Menu();
void initMenu();
};
--------------------------------------------------------
void Menu::setMatrix() {
..
..
controller = new Controller(knotenanzahl);
..
..
..
}
--------------------------------------------------------
I can't write something like controller(knotenanzahl), because I have to
declare it before I know the value of knotenanzahl.
I need to use Controller in my whole Menu class so declaring it as
static object in the setMatrix method only is no solution.
Markus
I have a class "Menu". In this class I declare an object "Controller".
Now I have a problem:
Controller uses a ctor but I get the value I have to pass later in my
program.
The only way to solve this is to make a new instance of "Controller" and
use it dynamically, but how can I use it as static object?
class Menu {
private:
int knotenanzahl;
Controller *controller;
void setMatrix();
public:
Menu();
virtual ~Menu();
void initMenu();
};
--------------------------------------------------------
void Menu::setMatrix() {
..
..
controller = new Controller(knotenanzahl);
..
..
..
}
--------------------------------------------------------
I can't write something like controller(knotenanzahl), because I have to
declare it before I know the value of knotenanzahl.
I need to use Controller in my whole Menu class so declaring it as
static object in the setMatrix method only is no solution.
Markus