class ABC{ public: void init(); private: int x, y; };
void ABC::init(){ x = 0; y = 0; } void ABC::init(){ (*this).x = 0; (*this).y = 0; }
#include<iostream.h> class demo{ public: demo& foo1(); demo& foo2(); demo& foo3(); }; demo& demo::foo1() { cout << "Calling foo1()..." << endl; return *this; } demo& demo::foo2() { cout << "Calling foo2()..." << endl; return *this; } demo& demo::foo3() { cout << "Calling foo3()..." << endl; return *this; } int main() { demo chain; chain.foo1().foo2().foo3(); //Chained function calls return(0); } Output: Calling foo1()... Calling foo2()... Calling foo3()...