Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Character
- {
- public:
- Character();
- ~Character();
- int* CharacterAge;
- float* CharacterHealth;
- };
- int main()
- {
- Character* Char = new Character;
- delete Char;
- system("pause");
- }
- Character::Character()
- {
- cout << "A new character was created" << endl;
- // Dynamically create an int and float on the heap
- CharacterAge = new int(1);
- CharacterHealth = new float(100.f);
- }
- Character::~Character()
- {
- cout << "Character destroyed" << endl;
- delete CharacterAge;
- delete CharacterHealth;
- }
Advertisement
Add Comment
Please, Sign In to add comment