Article View: gnu.g++.bug
Article #486strng.h
From: Jeffrey A Waller
Date: Mon, 09 Oct 1989 23:00
Date: Mon, 09 Oct 1989 23:00
51 lines
1420 bytes
1420 bytes
#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
Technical Details
Message-ID:
<8910092300.AA26351@cssun.tamu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!tut.cis.ohio-state.edu!CSSUN.TAMU.EDU!jeffwShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!tut.cis.ohio-state.edu!CSSUN.TAMU.EDU!jeffw From: jeffw@CSSUN.TAMU.EDU (Jeffrey A Waller) Newsgroups: gnu.g++.bug Subject: strng.h Message-ID: <8910092300.AA26351@cssun.tamu.edu> Date: 9 Oct 89 23:00:19 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 51