add pointer
add "dynamic" heap array add polymorphic
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user