#include<iostream> using namespace std; class Demo { private: int dwint; public: Demo(int i=0):dwint(i) { cout<<"default constructor called !"<<endl; } Demo(const Demo& d ) { dwint=d.dwint; cout<<"copy constructor called !"<<endl; } ~Demo() { cout<<"desconstructor called !"<<endl; } const Demo& operator=(const Demo& a ) { this->dwint=a.dwint; cout<<"assignment operator used"<<endl; return *this; } }; Demo func(Demo d) { Demo demo; demo=d; return demo; } int main() { Demo a(4); { Demo b; b=func(a); } Demo c=a; return 0; }