add containers
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include <iostream>
|
||||
#include <Windows.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "functions.h"
|
||||
#include "ClassA.h"
|
||||
#include "ClassB.h"
|
||||
@@ -115,8 +117,8 @@ int main()
|
||||
//cout << n << endl;
|
||||
//classB.GetNumber();
|
||||
|
||||
IPrintable* pPrintable = nullptr;
|
||||
pPrintable = new ClassB();
|
||||
//IPrintable* pPrintable = nullptr;
|
||||
//pPrintable = new ClassB();
|
||||
//(*pPrintable).Print();
|
||||
//pPrintable->Print(); // same line as above, but simpler
|
||||
////ClassB* pClassB2 = (ClassB*)pPrintable; // C-Cast, CAUTION: DANGER!!!
|
||||
@@ -138,7 +140,39 @@ int main()
|
||||
|
||||
//delete pPrintable;
|
||||
//pPrintable = nullptr;
|
||||
safeDelete(pPrintable);
|
||||
//safeDelete(pPrintable);
|
||||
|
||||
//vector<int> numbers = { 0, 1, 2, 30, 5, 456 };
|
||||
//cout << "numbers size/capacity: " << numbers.size() << " / " << numbers.capacity() << endl;
|
||||
//numbers.push_back(999);
|
||||
//cout << "numbers size/capacity: " << numbers.size() << " / " << numbers.capacity() << endl;
|
||||
//numbers[3] = 67;
|
||||
//
|
||||
//list<int> numbers2 = { 0, 1, 2, 30, 5, 456 };
|
||||
//list<int>::iterator it = numbers2.begin();
|
||||
//for (; it != numbers2.end(); it++)
|
||||
//{
|
||||
// //*it *= 2;
|
||||
// cout << *it << " ";
|
||||
//}
|
||||
//cout << endl;
|
||||
|
||||
//numbers2.insert(--it, 999);
|
||||
|
||||
//for (it = numbers2.begin(); it != numbers2.end(); it++)
|
||||
//{
|
||||
// //*it *= 2;
|
||||
// cout << *it << " ";
|
||||
//}
|
||||
//cout << endl;
|
||||
|
||||
const size_t count = 5;
|
||||
int numbers[count]; // const size -> stack array
|
||||
|
||||
size_t count2 = 10;
|
||||
int* numbers2 = new int[count2]; // dynamic size -> heap array
|
||||
delete[] numbers2;
|
||||
numbers2 = nullptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user