+ 1

Given "MyClass obj = new MyClass;". What is stored in obj?(in C++)

In Java, the statement, “MyClass obj = new MyClass;”, means that obj stores the address of class. Is it remained the same in C++?

14th Dec 2016, 5:37 PM
CYKuo
CYKuo - avatar
1 Réponse
+ 2
Yes, it's roughly the same in C++ as in Java. "obj" is a *pointer* to an object/instance, meaning it contains the memory address of the place in memory that actually stores the contents of the object.
14th Dec 2016, 7:00 PM
Álvaro