-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
96 lines (81 loc) · 1.7 KB
/
test.cpp
File metadata and controls
96 lines (81 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
#include <memory>
#include <string>
#include <cmath>
#include <vector>
#include "utils.hpp"
#include "Dependencies/eigen/Eigen/Dense"
using namespace std;
#define print(x) std::cout << x << std::endl;
class Animal
{
protected:
int legCount;
float size;
Animal(int legCount, float size) : legCount(legCount), size(size) {}
public:
virtual void info(){};
};
class Dog : public Animal
{
public:
string name;
// constructor
Dog(string name , int lC, float size) : name(name), Animal(lC, size)
{
print("Dog " + name + " created!");
}
// copy constructor
Dog(const Dog &other) : name(other.name + "_copy"), Animal(other.legCount, other.size)
{
print("Dog " + name + " Copied!")
}
// deconstructor
~Dog()
{
print("Dog " + name + " destroyed!")
}
void info(){
print("info:");
cout << "legCount:" ; print(legCount);
cout << "name:" ; print(name);
cout << "size:" ; print(size);
print("\n");
}
};
int main()
{
// Dog* ptr;
//polymorphic
// vector<Dog> v;
// for (int i = 0; i< 3; i++)
// {
// //polymorphic: Dog added but storage is animal
// // ptr = new Dog(std::to_string(i),1, 2);
// // print(ptr);
// print(std::to_string(i)+"------");
// v.emplace_back(
// Dog(std::to_string(i),1, 2)
// );
// }
// //polymorphic info function used from Dog class
// print(v.size());
// print("=========")
// for (int i= 0; i<v.size(); i++){
// v[i].info();
// }
// // delete &v[0];
// v.erase(v.begin()+2);
// print(v.size());
// print("=========")
// for (int i= 0; i<v.size(); i++){
// v[i].info();
// }
// Eigen::MatrixXf m;
// Eigen::Vector3f out;
// Eigen::Vector2f in;
// m = m.Random(5,2);
// m(0,0) = 1;
// print(m);
return 0;
}