Paste: rvalue destruction
| Author: | j |
| Mode: | c++ |
| Date: | Thu, 11 Nov 2010 05:10:15 |
Plain Text |
#include <iostream>
using namespace std;
class foo {
int buh;
public:
foo(int _buh) : buh(_buh) {}
~foo() { buh = 0; }
int &bar() { return buh; }
};
int main() {
cout << foo(5).bar() << "\n";
}
| Author: | j |
| Mode: | c++ |
| Date: | Thu, 11 Nov 2010 05:14:45 |
Plain Text |
#include <iostream>
using namespace std;
class foo {
char test[10];
public:
foo() { strcpy(test, "lol c++"); }
~foo() { strcpy(test, "hurr c++"); }
char *bar() { return test; }
};
int main() {
cout << foo().bar() << "\n";
}
New Annotation