0
class Test {
public:
    int var;
    Test() {
        var = 12;
    }
};

int main() {
    Test* t1 = new Test();
    Test* t2 = new Test;

    std::cout << t1->var << " " << t2->var << std::endl;
}

Here i have created two objects one with Test() and other with Test so, is there any difference by removing the parenthesis as the constructor is called in both the cases coz i'm getting the output as 12 from both t1->var and t2->var

vu_29
  • 15
  • 3

0 Answers0