In C++ do you always have initialize a pointer to an object with the new keyword?
new
Or can you just have this too:
MyClass *myclass; mycl
Simple solution for cast pointer to object
Online demo
class myClass { public: void sayHello () { cout << "Hello"; } }; int main () { myClass* myPointer; myClass myObject = myClass(* myPointer); // Cast pointer to object myObject.sayHello(); return 0; }