#include "mystring.h" mystring::mystring( ) { ptr = NULL ; } //Copy constructor mystring::mystring( const mystring& obj1 ) { printf( "Inside the copy constructor.\n" ) ; if ( obj1.ptr == NULL ) { ptr = NULL ; } else { int len = strlen( obj1.ptr ) + 1; ptr = new char[ len ] ; strcpy ( ptr, obj1.ptr ) ; } } mystring::mystring( const char* str1 ) { cout << "Inside the constructor." << endl ; if ( str1 == NULL ) ptr = NULL ; else { int len = strlen( str1 ) + 1; ptr = new char[ len ] ; strcpy ( ptr, str1 ) ; } } mystring::~mystring() { cout << "Inside the destructor." << endl ; if ( ptr != NULL ) delete[] ptr ; } void mystring::print() { cout << ptr << endl ; }