Best read up about inheritance, polymorphism and virtual functions, as well as abstract base classes (pure virtual functions).
Not using virtual correct can mean overhead and headaches.
Also,...
Type: Posts; User: Elysia
Best read up about inheritance, polymorphism and virtual functions, as well as abstract base classes (pure virtual functions).
Not using virtual correct can mean overhead and headaches.
Also,...
I believe the rule is that if you have a virtual function, the destructor should be virtual since it implies you are going to use polymorphism. Inheritance does not necessarily mean you are going to...
But as said, pointers do not actually create objects. They will point to them, and it's your job to thus create objects and make sure those pointers actually point to those objects later.
There's...
Use pointers to point to the same object. Like when you need to keep references to objects.
When you do not need pointers, do not use them.
http://apps.sourceforge.net/mediawiki/cpwiki/index.php?title=Common_mistakes_and_errors#Using_pointers_without_allocating_them
Does P1 point to a valid instance?
I assume you are doing this?
player* p1;
p1->whatever();
If yes, then Meldreth has already told you the answer.
A pointer is a variable that contains a memory address. It does not create...