CJCoding With Joseph
15free / daySign inCreate account

Hospital Inheritance

A base class Patient has been provided with protected members id (int) and name (string), a constructor, and a virtual print() function that prints the id and name.

A derived class InPatient publicly inherits from Patient and has an additional int roomNumber. The constructor has already been implemented.

Your task is to implement the overridden print() function for InPatient. It should print three lines:
ID: [id]
Name: [name]
Room: [roomNumber]

Do NOT include a main function. Your code will be tested automatically.

Expected Output:

ID: 101
Name: John
Room: 305

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
Inheritance
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.