#include<iostream.h>
#include<conio.h>
#include<string.h>
class string
{
char *ptr;
int len;
public:
string(char *s)
{
len=strlen(s);
ptr=new char[len];
strcpy(ptr,s);
}
~string()
{
delete ptr;
}
int operator !()
{
if(len==0)
return(1);
else
return(0);
}
void display()
{
cout<<"\n\nString is : "<<ptr;
}
};
int main()
{
clrscr();
char str[20];
cout<<"\n\nEnter a string : ";
cin>>str;
string s1(str),s2("");
if(!s1)
cout<<"\n\nString is empty";
else
s1.display();
if(!s2)
cout<<"\n\nString is empty";
else
s1.display();

getch();
return(0);
}

Post a Comment

Previous Post Next Post