while(alive){eat();code();sleep();}
Always take notes, learn from your failures:
- If you can't explain it simply, you don't know it well enough.
- Plan ahead for variable lifespan until it becomes a habit.
Delete
destroys thepointer to object
and assigns an invalid address. That invalid address is the wreckage of that destruction. You still have access to crash the program.- Avoid bare pointers.
- Nobody needs raw pointers where smarts are enough.
- Don't allocate memory as much as possible.
- Avoid returning a local object by reference.
- Don't pass an Object by Value.
- The STL part of the library is generally not meant to be derived from. It uses generic programming, and generally avoids
OOP
.