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 ยบ [==;>=]
- {
- return (this->str[0]==s.str[0]) ? true : false;
- }
- bool TString::operator!=(const TString &s)const
- {
- return (this->str[0]!=s.str[0]) ? true : false;
- }
- bool TString::operator<(const TString &s)const
- {
- return (this->str[0]<s.str[0]) ? true : false;
- }
- bool TString::operator>(const TString &s)const
- {
- return (this->str[0]>s.str[0]) ? true : false;
- }
- bool TString::operator<=(const TString &s)const
- {
- return (this->str[0]<=s.str[0]) ? true : false;
- }
- bool TString::operator>=(const TString &s)const
- {
- return (this->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;
- }
- int GetLength(const TString &s)
- {
- return s.str[0];
- }
- TString ClearPoz(TString &s)
- {
- TString sop,temp;
- sop.str=new char[strlen(s.str)+1];
- sop.str[0]=strlen(s.str)-1;
- strcpy(sop.str+1,s.str+1);
- temp.str= new char[sop.str[0]+1];
- temp.str[0]=strlen(temp.str)-1;
- //strcpy(temp.str+1,temp.str);
- int n=0,poz=0,i=0,j=0;
- //cout<<"Input poz and n\n";
- //cin>>poz>>n ;
- }
- TString TString::s1_in_s2(const TString &s)
- {
- int poz;
- //poz=strlen(this->str)+strlen(s.str)-2;
- str=new char[str[0]+1];
- str[0]=strlen(str)-1;
- poz=2;
- for(int i=0;i<strlen(sz);i++)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement