-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht_dyn.cpp
More file actions
53 lines (46 loc) · 1.11 KB
/
t_dyn.cpp
File metadata and controls
53 lines (46 loc) · 1.11 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
#include <iostream>
#define _COUT(...) { cout << __VA_ARGS__; } while (0)
#ifndef DOCOUT
#define COUT(...) _COUT("\t"<<__VA_ARGS__)
#define TRACE(...) _COUT(#__VA_ARGS__<<endl);__VA_ARGS__
#else
#define COUT(...)
#define TRACE(...) __VA_ARGS__
#endif
using std::cout;
using std::endl;
class X {
int x;
public:
//X(int v=-1): x(v) { cout << this<<" init "<<v<<endl;};
X(int v=-1): x(v) { COUT(this<<" init "<<v<<endl);};
#if ! defined( DOCOUT ) && defined(NODEF_EMPTY)
#else
~X() { COUT(this<<"("<<x<<") destroy"<<endl);};
#endif
X(const X& y) { COUT(this<<" copy from "<<&y<<" ("<<y.x<<")"<<endl);x=y.x;};
X(const X&& y) { COUT(this<<" z from "<<&y<<" ("<<y.x<<")"<<endl);x=y.x;};
X& operator=(const X& y) { COUT(this<<" assigning from "<<&y<<" ("<<y.x<<")"<<endl);x=y.x; return *this;};
};
X z(const int n=56) {
X ret=n;
return ret;
//return n;
//return X(X(X(X(X(X(ret))))));
}
X& leak(const int n=352) {
X& ret=*new X(n);
return ret;
}
int main() {
TRACE(X a,b,c=5;)
TRACE(b=10;)
TRACE(X d=z(60);)
TRACE(X f=d;)
TRACE(d=z(70);)
TRACE(b=c;)
TRACE(b=leak(100);)
TRACE(X e=leak(110);)
cout <<"END"<<endl;
return 0;
}