[Class]


class String
{
public:
  //
  // constructor
  //
  String()                               { cout << this << "::constructor() "; }
  String(char* p)                        { cout << this << "::constructor(char*) "; }
  String(const char* p)                  { cout << this << "::constructor(const char*) "; }
  String(const String& rhs)              { cout << this << "::constructor(const " << &rhs << "::String&) "; }

  //
  // destructor
  //
  virtual ~String()                      { cout << this << "::destructor "; }

  //
  // operator
  //
  String& operator = (char* p)           { cout << this << "::operator=(char*) ";        return *this; }
  String& operator = (const char* p)     { cout << this << "::operator=(const char*) ";  return *this; }
  String& operator = (const String& rhs) { cout << this << "::operator=(const " << &rhs << "::String) ";  return *this; }
};




[Test]


String g_s;                              // 0x406020::constructor() 



String s("test");                       // 0x22fef4::constructor(const char*) 
                                        // 0x22fef4::destructor 

String s = "test";                      // 0x22fef0::constructor(const char*) 
                                        // 0x22fef0::destructor 

String s;                               // 0x22feec::constructor() 
s = "test";                             // 0x22feec::operator=(const char*) 
                                        // 0x22feec::destructor 

String s(g_s);                          // 0x22fee8::constructor(const 0x406020::String&) 
                                        // 0x22fee8::destructor 

String s = g_s;                         // 0x22fee4::constructor(const 0x406020::String&) 
                                        // 0x22fee4::destructor 

String s;                               // 0x22fee0::constructor() 
s = g_s;                                // 0x22fee0::operator=(const 0x406020::String) 
                                        // 0x22fee0::destructor 

const char* p = "test";                    
String s(p);                            // 0x22fedc::constructor(const char*) 
                                        // 0x22fedc::destructor 

char* p = "test";                    
String s(p);                            // 0x22fed8::constructor(char*) 
                                        // 0x22fed8::destructor 

pointer_param_test(&g_s);                    


reference_param_test(g_s);                    


object_param_test(g_s);                 // 0x22fefc::constructor(const 0x406020::String&) 0x22fefc::destructor 


pointer_return_test();                    


String* s;                    
s = pointer_return_test();                    


String& s = reference_return_test();                    


String s = reference_return_test();     // 0x22feec::constructor(const 0x406020::String&) 
                                        // 0x22feec::destructor 

String s;                               // 0x22fee8::constructor() 
s = reference_return_test();            // 0x22fee8::operator=(const 0x406020::String) 
                                        // 0x22fee8::destructor 

object_return_test();                   // 0x22fef0::constructor(const 0x406020::String&) 0x22fef0::destructor 


String s(object_return_test());         // 0x22fee4::constructor(const 0x406020::String&) 
                                        // 0x22fee4::destructor 

String s = object_return_test();        // 0x22fee0::constructor(const 0x406020::String&) 
                                        // 0x22fee0::destructor 

String s;                               // 0x22fedc::constructor() 
s = object_return_test();               // 0x22fef4::constructor(const 0x406020::String&) 0x22fedc::operator=(const 0x22fef4::String) 0x22fef4::destructor 
                                        // 0x22fedc::destructor 


                                        // 0x406020::destructor 




[Download]


param_return_test.zip