jeffw@CSSUN.TAMU.EDU (Jeffrey A Waller) (10/10/89)
#ifndef __string
#define __string
#include <stream.h>
#include <string.h>
class string
{ friend ostream &operator<<(ostream &output,string &s);
private:
char *dataptr;
public:
string(int size = 0)
{ if(size > 0) dataptr = new char[size];
else dataptr = 0;
}
string(char *copyfrom)
{ if(copyfrom)
{ dataptr = new char[strlen(copyfrom) + 1];
if(dataptr) strcpy(dataptr,copyfrom);
}
else dataptr = 0;
}
string(string &s)
{ if(s.dataptr)
{ dataptr = new char[strlen(s.dataptr) + 1];
if(dataptr) strcpy(dataptr,s.dataptr);
}
else dataptr = 0;
}
string &operator=(string &s);
string operator+(string &s);
int operator==(string &s)
{ if(dataptr && s.dataptr) return(!strcmp(dataptr,s.dataptr));
else return(FALSE);
}
~string()
{ delete dataptr;
}
};
#endif