Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include "Person.h"
- TString::TString()
- {
- char buf[100];
- sprintf(buf,"Wet under foot");
- str = new char[strlen(buf)+1];
- strcpy(str+1, buf);
- str[0]=strlen(str)-1;
- }
- TString::TString(char* Str)
- {
- this->str=new char [strlen(Str)+1];
- this->str[0]=strlen(Str);
- strcpy(this->str+1,Str);
- }
- TString::TString(const TString &ob)
- {
- this->str=new char[strlen(ob.str)+1];
- strcpy(this->str+1,ob.str+1);
- str[0]=strlen(ob.str)-1;
- }
- TString::~TString()
- {
- delete[]str;
- }
- void TString::operator=(const TString &s)
- {
- TString sop(s);
- delete[]str;
- str=new char[strlen(s.str)+1];
- strcpy(str,s.str);
- }
- TString TString::operator+(const TString &s2)const
- {
- TString sop;
- int sz=strlen(str)+strlen(s2.str)-2;
- sop.str=new char[sz+1];
- sop.str[0]=sz;
- strcpy(sop.str+1,str+1);
- strcat(sop.str,s2.str+1);
- return sop;
- }
- TString TString::operator%(TString &s2)//--------------------(!!!!!)
- {
- TString sop;
- int sz;
- sz=strlen(str)+strlen(s2.str)-2;
- sop.str=new char[sz+1];
- sop.str[0]=sz;
- strcpy(sop.str+1,this->str+1);
- bool flag;
- for(int i=1,k=strlen(sop.str)-1; i<strlen(sop.str); i++)
- {
- flag=true;
- for(int j=1;j<strlen(s2.str);j++)
- {
- if(sop.str[i]==s2.str[j])
- {
- flag=false;
- break;
- }
- }
- if(flag)
- {
- sop.str[k]=s2.str[i];
- sop.output();
- k++;
- }
- }
- }
- bool TString::operator==(const TString &s)const// length compare º [==;>=]
- {
- TString sop;
- sop=new char[strlen(str)+1];
- sop.str[0]=strlen(str)-1;
- strcpy(sop.str+1,s.str+1);
- return (sop.str[0]==s.str[0]) ? true : false;
- }
- bool TString::operator!=(const TString &s)const
- {
- TString sop;
- sop=new char[strlen(str)+1];
- sop.str[0]=strlen(str)-1;
- strcpy(sop.str+1,s.str+1);
- return (sop.str[0]!=s.str[0]) ? true : false;
- }
- bool TString::operator<(const TString &s)const
- {
- TString sop;
- sop=new char[strlen(str)+1];
- sop.str[0]=strlen(str)-1;
- strcpy(sop.str+1,s.str+1);
- return (sop.str[0]<s.str[0]) ? true : false;
- }
- bool TString::operator>(const TString &s)const
- {
- TString sop;
- bool flag=0;
- sop=new char[strlen(str)+1];
- sop.str[0]=strlen(str)-1;
- strcpy(sop.str+1,s.str+1);
- return (sop.str[0]>s.str[0]) ? true : false;
- }
- bool TString::operator<=(const TString &s)const
- {
- TString sop;
- sop=new char[strlen(str)+1];
- sop.str[0]=strlen(str)-1;
- strcpy(sop.str+1,s.str+1);
- return (sop.str[0]<=s.str[0]) ? true : false;
- }
- bool TString::operator>=(const TString &s)const
- {
- TString sop;
- sop=new char[strlen(str)+1];
- sop.str[0]=strlen(str)-1;
- strcpy(sop.str+1,s.str+1);
- return (sop.str[0]>=s.str[0]) ? true : false;
- }
- void TString::input()
- {
- char buffer[100];
- cout<<"Input string\n";
- cin.getline(buffer,100);
- delete[]str;
- str[0]=strlen(buffer)-1;
- str=new char[str[0]+1];
- str=strdup(buffer);
- SetStr(str);
- }
- void TString::output()
- {
- cout<<endl<<"You have inputed : "<<endl;
- for (int i=1;i<strlen(str);i++)
- {
- cout<<str[i];
- }
- cout<<endl;
- cout<<"Size = "<<(int)str[0]<<endl<<endl;
- }
- TString GetLength(const TString &s)
- {
- TString sop;
- sop=new char[strlen(sop.str)+1];
- sop.str[0]=strlen(sop.str)-1;
- cout<<(int)s.str[0];
- }
- TString NClearPoz(const TString&s)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement