Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Jeffrey A Waller
Mon, 09 Oct 1989 23:00
strng.h
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads