CJCoding With Joseph
15free / daySign inCreate account
Back to Multiple Choice Quiz

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics

Private Member in Base Class

C++ quiz · Question 24
easyInheritance

This code fails to compile. What is the issue?

Code

1#include <iostream>
2using namespace std;
3 
4class Animal {
5private:
6 string name;
7public:
8 Animal(string n) : name(n) {}
9};
10 
11class Dog : public Animal {
12public:
13 Dog(string n) : Animal(n) {}
14 void print() {
15 cout << name << endl;
16 }
17};