Commit 9b4ab1c1028e3df1d9058c387e377856af803a60

Authored by Grzegorz Jabłoński
1 parent 335930b8

Added Dummy class to test vector operations

examples11/04-vectortmpl/testvector.cpp
... ... @@ -7,6 +7,33 @@ template<class C> void printvector (vector<C> v)
7 7 cout << v << endl;
8 8 }
9 9  
  10 +
  11 +class Dummy {
  12 + public:
  13 + Dummy()
  14 + {
  15 + cout << "Dummy default constructor" << endl;
  16 + };
  17 + Dummy(const Dummy&)
  18 + {
  19 + cout << "Dummy copy constructor" << endl;
  20 + };
  21 + Dummy(Dummy&&)
  22 + {
  23 + cout << "Dummy move constructor" << endl;
  24 + };
  25 + Dummy(int)
  26 + {
  27 + cout << "Dummy int constructor" << endl;
  28 + };
  29 +
  30 + Dummy(int,double)
  31 + {
  32 + cout << "Dummy int,double constructor" << endl;
  33 + };
  34 +
  35 +};
  36 +
10 37 int
11 38 main ()
12 39 {
... ... @@ -63,4 +90,15 @@ main ()
63 90 d=c;
64 91 cout << "Vector assigned" << endl;
65 92 printvector(d);
  93 +
  94 + vector<Dummy> dd(10);
  95 + Dummy dv;
  96 + dd.push_back(dv);
  97 + dd.push_back(Dummy());
  98 + dd.push_back(7);
  99 + dd.emplace_back(7);
  100 + dd.emplace_back(7,3.5);
  101 + dd.emplace_back(7);
  102 + dd.emplace_back(7);
  103 +
66 104 }
... ...