-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
43 lines (40 loc) · 947 Bytes
/
test.cpp
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
#include <iostream>
#include <vector>
class TENSOR {
public:
TENSOR() {
std::cout << "Default constructor called\n";
}
~TENSOR() {
std::cout << "Default destructor called\n";
}
TENSOR(const TENSOR& other) {
val = other.val;
std::cout << "Copy constructor called\n";
}
#if 1
TENSOR& operator=(const TENSOR& other) {
if (this == &other) return *this;
this->val = other.val;
std::cout << "Assigned operator called\n";
return *this;
}
#else
TENSOR operator=(TENSOR other) {
if (this == &other) return *this;
this->val = other.val;
std::cout << "Copy operator called\n";
return *this;
}
#endif
std::vector<int> val;
};
TENSOR modification(const TENSOR& tensor) {
TENSOR result = tensor;
return result;
}
int main() {
TENSOR test;
test.val.push_back(5);
TENSOR abc = modification(test);
}