home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programming
/
powerprogramming1994.iso
/
progtool
/
microcrn
/
issue_40.arc
/
DAIMS.ARC
/
STRINGS.HXX
< prev
next >
Wrap
Text File
|
1988-02-10
|
1KB
|
53 lines
#include <stream.h>
#include <string.h>
/*
-*++ class string: see pp 184-186 in Stroustrup
**
** (*++ history:
** 7 Dec 87 Bruce Eckel Creation date
** ++*)
**
** (*++ detailed:
** ++*)
*/
class string {
public:
struct srep {
char *s;
int n;
};
srep *p;
string(char *); // string x = "abc";
string(); // string x;
string(string &); // string x = string ...
string& operator=(char *);
string& operator=(string &);
~string();
char & operator[](int i);
char* stringp() { return p->s;}
friend ostream& operator<<(ostream&, string&);
friend istream& operator>>(istream&, string&);
friend int operator==(string &x, char *s)
{ return strcmp(x.p->s, s) == 0;}
friend int operator==(string &x, string &y)
{ return strcmp(x.p->s, y.p->s) == 0;}
friend int operator!=(string &x, char *s)
{ return strcmp(x.p->s,s) != 0; }
friend int operator!=(string &x, string &y)
{ return strcmp(x.p->s,y.p->s) != 0; }
friend string& operator+(string& x, string& y);
void error(char *p) { cerr << p << "\n"; exit(1); }
};