0

When I write 'MyClass obj;' in C++, is obj a pointer or an object? Differences with Java

In java we write: MyClass obj to create the pointer and then: new MyClass(); to create the object, we use the equal sign (=) to tell the pointer to point to the newly created object. How does this work in C++? When I write: MyClass obj; Am I creating a pointer, an object or both at the same time? Can obj be null or point to another object like in Java?

4th Nov 2016, 8:07 AM
Elia Perantoni
Elia Perantoni - avatar
1 Antwort
0
"MyClass obj;" is in C++ an object. Pointers are marked with *. As example: *ptr This is a pointer.
4th Nov 2016, 2:31 PM
TheLastCookie
TheLastCookie - avatar