add pointer

add "dynamic" heap array
add polymorphic
This commit is contained in:
2025-03-26 12:44:05 +01:00
parent abb1ea4a38
commit 4b6ac6a484
13 changed files with 339 additions and 1 deletions
+17
View File
@@ -24,5 +24,22 @@ int main()
Vector3 position(1.0f, 3.0f, -5.0f);
position.y = 0.0f;
ICompareable* pComparable = nullptr;
pComparable = &ork;
pComparable->Compare(&ork);
(*pComparable).Compare(&ork); // same as line above, but more complicated to write
ICompareable* pComparables[] = { new Ork, new Ork, new Ork };
for (size_t i = 0; i < size(pComparables); i++)
{
//pComparables[i]->Compare(nullptr);
delete pComparables[i];
pComparables[i] = nullptr;
}
ICompareable** pHeapComparables = new ICompareable*[10];
delete[] pHeapComparables;
pHeapComparables = nullptr;
return 0;
}