[ create a new paste ] login | about

Link: http://codepad.org/lGNw5J5j    [ raw code | output | fork ]

C++, pasted on May 26:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
using namespace std;


struct B{
	 int b;
	 ~B(){cout <<"destruct B" << endl;}
};

B func(){
	B b;
	b.b = 1;
	return b;
}
int main(){
	const B& instance = (const B&)func(); 
	cout <<instance.b<<endl;
	return 0;
}


Output:
1
2
3
destruct B
destruct B
1


Create a new paste based on this one


Comments: