fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class CString
  6. {
  7. public:
  8. CString(){}
  9. CString(const string& str)
  10. {
  11. m_str = str;
  12. cout << "생성자:" << m_str << endl;
  13. }
  14. ~CString(){}
  15.  
  16. string m_str;
  17.  
  18. string& operator= (const string& str)
  19. {
  20. m_str = str;
  21. cout << "operator=" << m_str << endl;
  22. }
  23. };
  24.  
  25. int main()
  26. {
  27. CString str("test");
  28. str = "abc";
  29. return 0;
  30. }
  31.  
  32.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
생성자:test
operator=abc