#include <iostream>
using namespace std;
struct Tuna{
int x = 50;
Tuna() : x(200){
}
Tuna &foo(){
return *this; //return type is reference to Tuna class
}
/****************
Returns a new object made by copying the current object
*****************/
Tuna bar(){
return *this;
}
void set(int value) { x = value; }
};
int main(){
// a pointer to class
Tuna tt;
Tuna *foobar = &tt;
foobar->set(20);
cout << foobar->x << endl;
Tuna t;
t.foo().set(1);
cout << t.x << endl;
system("pause");
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IFR1bmF7CgoJaW50IHggPSA1MDsKCSBUdW5hKCkgOiB4KDIwMCl7CgkJCgl9CgoJIFR1bmEgJmZvbygpewoJCSByZXR1cm4gKnRoaXM7IC8vcmV0dXJuIHR5cGUgaXMgcmVmZXJlbmNlIHRvIFR1bmEgY2xhc3MKCSB9CgoKCSAvKioqKioqKioqKioqKioqKgoJIAoJIFJldHVybnMgYSBuZXcgb2JqZWN0IG1hZGUgYnkgY29weWluZyB0aGUgY3VycmVudCBvYmplY3QKCgkgKioqKioqKioqKioqKioqKiovCgkgVHVuYSBiYXIoKXsgCgkJIHJldHVybiAqdGhpczsKCSB9Cgkgdm9pZCBzZXQoaW50IHZhbHVlKSB7IHggPSB2YWx1ZTsgfQoKfTsKaW50IG1haW4oKXsKCgkvLyBhIHBvaW50ZXIgdG8gY2xhc3MKCVR1bmEgdHQ7CglUdW5hICpmb29iYXIgPSAmdHQ7Cglmb29iYXItPnNldCgyMCk7Cgljb3V0IDw8IGZvb2Jhci0+eCA8PCBlbmRsOwoKCgoJVHVuYSB0OwoJdC5mb28oKS5zZXQoMSk7Cgljb3V0IDw8IHQueCA8PCBlbmRsOwoKCglzeXN0ZW0oInBhdXNlIik7CgoJcmV0dXJuIDA7Cgp9