Question 3 Identify and correct errors in the following class declaration: class nifty { // data char personality[]; int talents: // methods nifty(); nifty(char* s);

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question
100%
W
FILE
Be
Paste
2
=
HOME INSERT
Times New Ro 12
BI Uabe X₂ X²
Font
Clipboard
DESIGN PAGE LAYOUT
Α Α΄ Aa
EE 。 AaBbCcDc AaBbCcDc AaBbC, AaBbCCE
Normal I No Spac... Heading 1 Heading 2
A-ay-
Paragraph
Г
Styles
G
TUTTCLOITS pemave.
Question 3
Identify and correct 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;
}
PAGE 1 OF 2 47 WORDS DX ENGLISH (UNITED STATES)
Document1 Word
REFERENCES MAILINGS REVIEW VIEW
E R
?
Find
ac Replace
Select
Editing
2
Sign in
X
90%
Transcribed Image Text:W FILE Be Paste 2 = HOME INSERT Times New Ro 12 BI Uabe X₂ X² Font Clipboard DESIGN PAGE LAYOUT Α Α΄ Aa EE 。 AaBbCcDc AaBbCcDc AaBbC, AaBbCCE Normal I No Spac... Heading 1 Heading 2 A-ay- Paragraph Г Styles G TUTTCLOITS pemave. Question 3 Identify and correct 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; } PAGE 1 OF 2 47 WORDS DX ENGLISH (UNITED STATES) Document1 Word REFERENCES MAILINGS REVIEW VIEW E R ? Find ac Replace Select Editing 2 Sign in X 90%
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,