Hey there ,
since I've came from c# to c++ everything looks crazy for me in c++. I just wondering If someone could explain me why do we have these kind of instantiating in c++ : method 1:
ClassA obj1; // this is going to stack
method 2:
ClassA *obj1 = new ClassA(); //this is going to heap
whereas we don't have the common instantiating in C# way on c++ :
ClassA obj2 = new obj2();
and one more question in method1 I get an instance from the ClassA but without the () and this is the exact place the I've got confused , why do we have to instatiating like that? our ClassA has an constructor but instantiating without parentheses??? how come we call its constructor?
p.s : I've read these topics :
http://stackoverflow.com/questions/677632/different-methods-for-instantiating-an-object-in-c
http://stackoverflow.com/questions/408670/stack-static-and-heap-in-c
http://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap