//STRING.CPP
//Реализация класса string(строка символов)
#include <iostream.h>
#include "string3spa.h"
#include <string.h>
string::string()
{ StrPtr=new char[(size=DEFSTR)+1];
strcpy(StrPtr,"");}

string::string(int SIZE)
{ StrPtr=new char[(size=SIZE)+1];
strcpy(StrPtr,"");
}

string::string(string& STRING)
{StrPtr=new char[(size=STRING.size)+1];
strcpy(StrPtr,STRING.StrPtr);
}

string&string::operator=(string&STRING)
{if(size<STRING.size)
 {delete[] StrPtr;
 StrPtr=new char[(size=STRING.size)+1];}
strcpy(StrPtr,STRING.StrPtr);
return *this;}

string&string::operator=(char*st)
{if(size<strlen(st))
 {delete[] StrPtr;
 StrPtr=new char[(size=strlen(st))+1];}
strcpy(StrPtr,st);
return *this;}

int string::operator==(string&STRING)
{return(strcmp(StrPtr,STRING.StrPtr)==0);}

int string::operator==(char *st)
{return(strcmp(StrPtr,st)==0);}

int operator==(char *st,string&STRING)
{return(strcmp(st,STRING.StrPtr)==0);}

int string::operator!=(string&STRING)
{return(strcmp(StrPtr,STRING.StrPtr)!=0);}

int string::operator!=(char *st)
{return(strcmp(StrPtr,st)!=0);}

int operator!=(char *st,string&STRING)
{return(strcmp(st,STRING.StrPtr)!=0);}

ostream&operator<<(ostream&stream,string&STRING)
{ stream<<STRING.StrPtr;
return stream;}

istream&operator>>(istream&stream,string&STRING)
{ stream>>STRING.StrPtr;
return stream;}

