#include <fstream.h>
#include <string.h>
class ShallowString	{
public:
	ShallowString(const char* nstr);
	void debug(ostream& out) const;
protected:
	int len;		//length of the string
	char *buf;	//buffer containing string
	};
typedef ShallowString String;

main()	{
	String *s1 = new String("This String Will Be Lost");
	ofstream &out = *new ofstream("test.dat");
	cout = out;
	s1->debug(out);
	delete s1;
	s1 = new String("This String Will Be Lost Too");
	s1->debug(out);
	}
/****** output *******************
len=24, buf=0x57a703d2,This String Will Be Lost
len=28, buf=0x57a70132,This String Will Be Lost Too
*********************************/

ShallowString::ShallowString(const char* nstr)	{
	len = strlen(nstr);
	buf = new char[len];
	memcpy(buf,nstr,len);
	}

void ShallowString::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;
	}
