add pointer in classes

add interfaces
This commit is contained in:
2025-09-23 12:42:50 +02:00
parent 89459f9cfc
commit 5894f4008e
10 changed files with 167 additions and 5 deletions
+20 -2
View File
@@ -2,6 +2,7 @@
#include "Entity.h"
#include "Monster.h"
#include "Vector3.h"
#include "Ork.h"
using namespace MyNamespace;
using namespace std;
@@ -11,12 +12,29 @@ int main()
Entity entity; // this is an instance
cout << entity.ToString() << endl;
Monster monster;
cout << monster.ToString() << endl;
// can't be instantiated, because it is abstract
//Monster monster;
//cout << monster.ToString() << endl;
Vector3 position(1.0f, 0.0f, 2.0f);
Vector3 position2 = Vector3();
Vector3 position3{}; // list-initializer
Ork ork;
ork.Move(position);
Monster* pMonster = new Ork();
delete pMonster;
pMonster = nullptr;
ICompareable* pCompareables[] = { new Ork, new Ork, new Ork };
for (size_t i = 0; i < size(pCompareables); i++)
{
delete pCompareables[i];
pCompareables[i] = nullptr;
}
Ork ork2 = ork;
return 0;
}