#include<iostream.h>
#include<conio.h>
#include<string.h>
class Str{
char *s;
public:
Str(){}
Str(char *t)
{
int l=strlen(t);
s=new char[l];
strpy(s,t);
cout<<"The string is="<<s<<"\n";
}
-Str()
{
delete s;
cout<<"After deleting="<<s;
}
};
void main()
{
clrscr();
Str S("Welcome");
getch();
}
Output:
The String is=Welcome
After deleting=Welcome
#include<conio.h>
#include<string.h>
class Str{
char *s;
public:
Str(){}
Str(char *t)
{
int l=strlen(t);
s=new char[l];
strpy(s,t);
cout<<"The string is="<<s<<"\n";
}
-Str()
{
delete s;
cout<<"After deleting="<<s;
}
};
void main()
{
clrscr();
Str S("Welcome");
getch();
}
Output:
The String is=Welcome
After deleting=Welcome
No comments:
Post a Comment