fork download
  1. #include<iostream>
  2. class Base{};
  3. class Derived : public Base
  4. {
  5. public:
  6. Derived(){}
  7. Derived(const Base &rhs)
  8. {
  9. std::cout<<"\n In conversion constructor";
  10. }
  11. const Derived &operator=(const Base &rhs)
  12. {
  13. std::cout<<"\n In operator=";
  14. return *this;
  15. }
  16. };
  17.  
  18. void doSomething(Derived obj)
  19. {
  20. std::cout<<"\n In doSomething";
  21. }
  22. int main()
  23. {
  24. Base obj1;
  25. doSomething(obj1);
  26.  
  27.  
  28. Derived obj2;
  29. obj2 = obj1;
  30. return 0;
  31. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
 In conversion constructor
 In doSomething
 In operator=