#include #include #include "Str.h" Str::Str():curPos(0){ str = new char[200]; } Str::Str(char* _str){ str = new char[200]; strcpy(str, _str); } Str::~Str(){ delete [] str; } bool Str::operator==(Str &src){ if(strcmp(src.getStr(), getStr()) == 0) return true; return false; } Str::Str(const Str& src) { str = new char [strlen(src.str)+1] ; strcpy(str,src.str); } Str& Str::operator =(const Str &src){ if(this!= &src) { delete [] str; str = new char [strlen(src.str)+1] ; strcpy(str,src.str); } return *this; } istream& operator >> (istream& is, Str &s){ char t,x; do{ if(is.peek() != '\n'){ t = is.get(); s.str[s.curPos++] = t; } else x= is.get(); }while(is.peek() != '\n'); s.str[s.curPos] = NULL; return is; }