Розробка власного класу STRING
Курсовой проект - Компьютеры, программирование
Другие курсовые по предмету Компьютеры, программирование
p>}
if (Notequal) return - 1;
else return pos;
}
"driver. cpp", .
#include
#include "TPstr. h"
using namespace std;
int main ()
{
clsString* temp=new clsString ("This program will test my work");
cout <<*temp<<endl;
*temp= (clsString)"This is a small driver";
clsString test1 ("Testing in process");
clsString test2;
clsString test3 (*temp);
cout<<*temp<<endl<<test1<<endl<<test2<<endl<<test3;
cout<<"\nEnter string"<<endl;
cin>>test2;
cout<<test2<<endl;
cout<<"Enter string"<<endl;
cin>>test2;
cout<<test2<<endl;
cout<<"s1 is \""<<test1<<"\" and s2 is \""<< test3<<"\""
<<"\n\nThe results of comparing is: "
<<"\ns2==s1 yields "
<< (test3==test1?"true": "false")
<<"\ns2! =s1 yields "
<< (test3! =test1?"true": "false")
s1 yields "
test1?"true": "false")
<<"\ns2<s1 yields "
<< (test3<test1?"true": "false")
<<"\ns2<=s1 yields "
<< (test3<=test1?"true": "false")
=s1 yields "
=test1?"true": "false") <<endl;
cout << "\n\ns1 += s2 yields s1 = ";
test1 += test3; // test overloaded concatenation
cout << test1<<endl;
test1 [0] =t;
test1 [1] =E;
cout<<"s1 after s1 [0] = t and s1 [1] =E"<<endl;
cout<<test1<<endl;
cout<<"find and delete in s1 s2"<<endl;
int pos=test1. find (test3);
test1. TPdelete (pos,test3. lenght ());
cout<<test1<<endl;
cout<<"**********************************************************\n";
test1="112211221122";
test3="334433443344334";
cout<<"\ns1 is \""<<test1<<"\" and s2 is \""<< test3<<"\"";
cout<<"Insert to s1 5 symbols from s2. Start position 0: "<<endl;
test1. insert (test3,0,5);
cout<<test1<<endl;
test1="112211221122";
test3="334433443344334";
cout<<"Insert to s1 5 symbols from s2. Start position 5: "<<endl;
test1. insert (test3,5,5);
cout<<test1<<endl;
test1="112211221122";
test3="334433443344334";
cout<<"Insert to s1 5 symbols from s2. Start position end of s1: "<<endl;
test1. insert (test3,test1. lenght (),5);
cout<<test1<<endl;
temp->~clsString ();
temp=new clsString ( (long) 2007);
cout<<*temp<<endl;
temp->~clsString ();
temp=new clsString (-12.34567890123);
cout<<*temp<<endl;
temp->~clsString ();
return 0;
}