Files

45 lines
893 B
C++

#include "ClassA.h"
#include <list>
int main() {
ClassA a{};
a.Print();
ClassA *pA = nullptr;
pA = new ClassA();
pA->Print();
// (*pA).Print(); // same line as above, but more complex to write
delete pA;
pA = nullptr;
a.CompareTo(pA);
IComparable *pComparable = nullptr;
pComparable = new ClassA();
pComparable->CompareTo(pA);
// pA = dynamic_cast<ClassA *>(pComparable);
delete pComparable;
pComparable = nullptr;
// copy object
ClassA a2 = a;
std::list<ClassA> list;
std::list<ClassA>::iterator it;
for (it = list.begin(); it != list.end(); ++it) {
it->Print();
}
std::list<IComparable*> list2;
std::list<IComparable*>::iterator it2;
for (it2 = list2.begin(); it2 != list2.end(); ++it2) {
(*it2)->CompareTo(&a);
}
IComparable* pComparables[10];
return 0;
}