Re Use Constructor?
| ProfN (7) |
|
Ok lets say I create a class and the constructor. Back in the main code a create an instance of the class 'Example':
When I try to use:
e.Example();
I get an error, is there any way to do it?
|
|
|
| helios (10126) |
|
1 2
|
Example e;
Example(); //This line does nothing, IINM
|
When I try to use:
e.Example();
I get an error, is there any way to do it? | No. You can't manually call constructors or destructors (well, you can in certain cases, but generally you shouldn't). What you can do is
1 2 3 4 5 6 7 8 9 10 11
|
class A{
A(){
this->init();
}
void init();
};
//...
A a;
//...
a.init();
|
|
|
|
| ProfN (7) |
|
|
Thanks for the tip :)
|
|
|
Topic archived. No new replies allowed.