Hi,
why this code does not work?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
class Name {
char *mp;
int mlen;
public:
Name(const char *pname) : mlen(strlen(pname)), mp(new char[mlen + 1])
{
strcpy(mp, pname);
}
void display()const
{
cout << mp << endl;
}
};
int main()
{
Name name("Firix bills");
name.display();
return 0;
}
|
Last edited on