fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class B
  5. {
  6. public:
  7. B(int x ) //default constructor
  8. {
  9. cout << "Constructor called" << endl;
  10. }
  11.  
  12. B(const B &b) //copy constructor
  13. {
  14. cout << "Copy constructor called" << endl;
  15. }
  16.  
  17. B& operator=(int rhs)
  18. {
  19. cout << "Assignment operator" << endl;
  20. }
  21. };
  22.  
  23. int main()
  24. {
  25.  
  26. B ob =5;
  27. ob=6;
  28. ob=7;
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
Constructor called
Assignment operator
Assignment operator