#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include<conio.h>
class string
{
char *s;
int length;
public:
string();
string(char*);
~string(); // Destructor declaration
};
string::string()
{
length = 0;
s = new char[length + 1];
s[0] = '\0'; // empty string
}
string::string(char *str)
{
length = strlen(str);
s = new char[length + 1];
strcpy(s,str);
}
string::~string() // Destructor definition
{
delete s;
cout << "One Object deleted...\n";
}
void main(void)
{
clrscr();
string s1("Good "),s2("Morning"),s3;
getch();
}
0 comments:
Post a Comment