When I create an object of a class, say,
class A {
public: A() {}
};
A a;
Is only the constructor called? Or is it that the new operator is used implicitly?
Like we have to do A* b = new A();
Also, where will a and b be stored in memory? Stack or heap?
In the first case, if
ais not a global variable, then it will be put on the stack, whilebwill be put on the heap.And in the first case, only the constructor is called.
newis never called except if you do it explicitly as in the second case.