Question: Identify and correct the errors in the following class declaration: class nifty { // data char personality[]; int talents; // methods nifty(); nifty(char * s);
Identify and correct the errors in the following class declaration:
class nifty
{
// data
char personality[];
int talents;
// methods
nifty();
nifty(char * s);
ostream & operator<<(ostream & os, nifty & n);
}
nifty:nifty()
{
personality = NULL;
talents = 0;
}
nifty:nifty(char * s)
{
personality = new char [strlen(s)];
personality = s;
talents = 0;
}
ostream & nifty:operator<<(ostream & os, nifty & n)
{
os << n;
}
Step by Step Solution
3.41 Rating (157 Votes )
There are 3 Steps involved in it
The declaration of the constructor in line 4 has ... View full answer
Get step-by-step solutions from verified subject matter experts
