#include <fstream.h>
#include <string.h>
class DeepString	{
public:
	DeepString(const char* nstr);
	DeepString(const DeepString& s);
	void debug(ostream& out) const;
protected:
	int len;		//length of the string
	char* buf;	//buffer containing string
	};
typedef DeepString String;

DeepString::DeepString(const char* nstr)	{
	len = strlen(nstr);
	buf = new char[len];
	memcpy(buf,nstr,len);
	}
DeepString::DeepString(const DeepString& s)	{
	len = s.len;
	buf = new char[len];
	memcpy(buf,s.buf,len);
	}

main()	{
	String s1("Hello World");
	String s2(s1);
	ofstream out("test.dat");
	s1.debug(out);	s2.debug(out);
	}
/****** output *******************
len=11, buf=0x581703e6,Hello World
len=11, buf=0x581703d6,Hello World
*********************************/

void DeepString::debug(ostream& out) const	{
	out << "len=" << dec << len
		 << ", buf=0x" << hex << (long)buf << ",";
	for(int i=0;i<len;i++)	{	out << buf[i];	}
	out << endl;
	}

