#include
#include
class string
{
private :
char *s;
int len;
public:
string()
{
len=0;
s=0;
}
string(char *c)
{
len= strlen(c);
s = new char[len+1];
strcpy(s,c);
}
void showstring()
{
cout<<"\nstring is : ";
cout<
friend void operator +(string & p,string & t)
{
string temp;
temp.len=p.len+t.len;
temp.s=new char [temp.len+1];
strcpy(temp.s,p.s);
strcat(temp.s,t.s);
cout<<"\nconcated string : " ;
cout<
friend void operator ==(string & p,string & t)
{
int m = strlen(p.s);
int n = strlen(t.s);
if(m==n)
cout<<"\ntwo strings are EQUAL";
else
cout<<"\ntwo strins are NOT equal";
}
friend void operator <=(string & p,string & t)
{
int m = strlen(p.s);
int n = strlen(t.s);
if(m<=n)
cout<<"\nstring: "<
cout<<"\nstring ~ "<
};
void main()
{
clrscr();
string a("networking"),b;
a.showstring();
b="electronics" ;
b.showstring();
a+b;
a<=b;
a==b;
getch();
}
No comments:
Post a Comment