I'm just beginning C++, having first done some Java and a lot of Python. In both of those languages there is exactly one way of creating a new variable of type MyClass
, in Java it's MyClass obj = new MyClass()
and in Python it's obj = MyClass()
.
In C++ I've seen all kinds of different syntaxes in example code, things like:
MyClass* obj = new Myclass();
MyClass obj();
MyClass obj = MyClass();
MyClass obj;
Where can I get an exhaustive list of all the different ways of instantiating a class in C++, and the differences between them? In case I'm using the terminology wrong, by "instantiating", I mean obtaining a variable name on which methods can be called with either dot or arrow notation.