Académique Documents
Professionnel Documents
Culture Documents
}
/* OUTPUT
Main block
Constructor
Inner block
Constructor
Destructor
Return back to main block
Destructor */
char *name;
public:
sample(){}
sample(char *s)
{
len=strlen(s);
name=new char(len+1);
strcpy(name,s);
}
void disp()
{
cout<<"The name ="<<name<<"\n";
}
};
int main()
{
char *str1="How";
char *str2="Hello how are you ?";
sample S1(str1);
sample S2(str2);
S1.disp();
S2.disp();
getch();
return 0;
}
/* OUTPUT
The name =How
The name =Hello how are you ? */