I have the following class:
class Test {
public:
Test() {
a = 33;
}
private:
int a;
};
When I want to create an instance of this class in eg java I do:
Test t = new Test();
but in C++ I either do:
1) Test t;
or
2) Test t();
(what are the difference between 1 and 2?).
I can't do:
Test t = new Test();
but is that not the only way to make sure the instance lives after the
calling function has returned?
class Test {
public:
Test() {
a = 33;
}
private:
int a;
};
When I want to create an instance of this class in eg java I do:
Test t = new Test();
but in C++ I either do:
1) Test t;
or
2) Test t();
(what are the difference between 1 and 2?).
I can't do:
Test t = new Test();
but is that not the only way to make sure the instance lives after the
calling function has returned?
Comment