CJCoding With Joseph
15free / daySign inCreate account
TitleOpen
124
Basic Public InheritanceA base class Animal has been provided with a protected string name, a constructor that initializes it, and a function getName() that returns the name.
easyNot startedSolve
125
Accessing Protected MembersA base class Person has been provided with a protected string name and a constructor that initializes it.
easyNot startedSolve
126
Constructor Call OrderA base class Vehicle has been provided with a protected int speed and a constructor that sets it.
easyNot startedSolve
127
Function OverridingA base class Shape has been provided with a virtual function draw() that prints "Drawing Shape".
easyNot startedSolve
128
Calling Base Using Scope ResolutionA base class Employee has been provided with a protected string name, a constructor, and a virtual function print() that prints the name.
easyNot startedSolve
129
Is-A RelationshipA base class Account has been provided with a protected double balance, a constructor, and a getBalance() function.
easyNot startedSolve
130
Base Pointer to Derived ObjectA base class Animal has been provided with a virtual function sound() that prints "Animal sound" and a virtual destructor.
easyNot startedSolve
131
Constructor and Destructor OrderA base class Base has been provided with a constructor that prints "Base constructor" and a virtual destructor that prints "Base destructor".
easyNot startedSolve
132
Overriding With Same SignatureA base class Printer has been provided with a virtual function print() that is marked const and prints "Printing".
easyNot startedSolve
133
Using Protected Instead of PrivateA base class BankAccount has been provided with a protected int accountNumber and a constructor that initializes it.
easyNot startedSolve
134
Multi Level InheritanceA three-level inheritance chain has been provided: - Person (base class) with a protected name and getName() function - Student (derived from Person) - GraduateStudent (derived from Student) Your task is to implement the printLevel() function for GraduateStudent.
easyNot startedSolve
135
Private Members and GettersA base class Book has been provided with a private string title, a constructor, and a public getter getTitle().
easyNot startedSolve
136
Override and Call Base FunctionA base class Message has been provided with a virtual function display() that prints "Message".
easyNot startedSolve
137
Hospital InheritanceA 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.
easyNot startedSolve
138
Employee Engineer InheritanceA base class Employee has been provided with protected members id (int) and name (string), a constructor, and a virtual print() function.
easyNot startedSolve
429
Passing Arguments to Base ConstructorCreate a base class Vehicle and a derived class Car.
easyNot startedSolve
430
Default Argument in Base ConstructorCreate a base class Greeter and a derived class EnglishGreeter.
easyNot startedSolve
431
Using the Override KeywordCreate a base class Bird with a virtual method string sound() const that returns "generic".
easyNot startedSolve
432
Inherited Method Without OverrideA derived class automatically inherits the public methods of its base.
easyNot startedSolve
433
Protected Helper MethodA protected method can be called by a derived class but not from outside the hierarchy.
easyNot startedSolve
434
Grandchild Calls Grandparent MethodIn a three-level hierarchy, the most-derived class inherits methods from ALL of its ancestors.
easyNot startedSolve
435
Polymorphism Through a Base ReferenceVirtual dispatch works through base REFERENCES, not only pointers.
easyNot startedSolve
436
Virtual Destructor CleanupWhen you delete a derived object through a base pointer, the base destructor MUST be virtual so the derived destructor also runs.
easyNot startedSolve
437
Preventing Override With FinalThe final specifier stops a virtual method from being overridden by any further subclass.
easyNot startedSolve
438
Age Check Using an Inherited FieldA derived class can build new logic on top of a field it inherits.
easyNot startedSolve
439
Sharing a Static Constant Through InheritanceA static member of a base class is shared by the base and every derived class.
easyNot startedSolve
440
Reusing an Inherited Setter and GetterWhen base data is private, a derived class cannot touch it directly and must go through the inherited public accessors.
easyNot startedSolve
139
Derived Class With New MembersYou are given a base class Shape with a protected string color and a constructor.
mediumNot startedSolve
140
Polymorphism Through Base PointerYou are given a base class Animal with a virtual function speak() that prints "..." and a virtual destructor.
mediumNot startedSolve
141
Inheriting and Extending a ConstructorYou are given a base class Person with protected members name (string) and age (int), plus a constructor and a virtual display() function.
mediumNot startedSolve
142
Override With Base Call and Extra LogicYou are given a base class Logger with a virtual function log() that prints a timestamp message.
mediumNot startedSolve
143
Multi-Level Inheritance With OverridesYou are given a base class Vehicle with a protected int speed and a virtual function describe().
mediumNot startedSolve
144
Virtual Function With Return ValueYou are given a base class Employee with protected members name (string) and baseSalary (double), a constructor, and a virtual function calculatePay() that returns baseSalary.
mediumNot startedSolve
289
Derived Class Adds a MethodThe base class Vehicle stores a protected speed and has a getSpeed() method.
mediumNot startedSolve
441
Name Hiding in a Derived ClassWhen a derived class declares ANY method with a given name, it hides ALL base methods of that same name (even overloads with different parameters).
mediumNot startedSolve
442
Using Declaration to Unhide Base OverloadsA using declaration brings hidden base overloads back into a derived class's scope so they can be called WITHOUT qualification.
mediumNot startedSolve
443
Protected Inheritance AccessWith protected inheritance, the base class's PUBLIC members become PROTECTED in the derived class: outside code can no longer call them, but the derived class's own methods still can.
mediumNot startedSolve
444
Private Inheritance BasicsWith private inheritance, the base class's public interface becomes PRIVATE in the derived class.
mediumNot startedSolve
445
Multiple Inheritance BasicsA class can inherit from more than one base class at the same time, gaining the members of all of them.
mediumNot startedSolve
446
Downcasting With static_castA static_cast can convert a base pointer down to a derived pointer when you already know the real object type, letting you call methods that only exist on the derived class.
mediumNot startedSolve
447
Object Slicing DemonstrationCopying a derived object into a base OBJECT (by value) slices off the derived part, and virtual dispatch no longer reaches the override.
mediumNot startedSolve
448
Interface With Two Pure Virtual MethodsAn interface is an abstract class made only of pure virtual methods.
mediumNot startedSolve
449
Counting Objects With a Static Base MemberA static data member in a base class is shared across the whole hierarchy, so it can count every object created, including derived ones.
mediumNot startedSolve
290
Abstract Base Class With Pure VirtualThe abstract base class Shape declares a PURE VIRTUAL method area() (it has no body, ending in = 0).
hardNot startedSolve
291
Polymorphic Array of ShapesThe abstract base class Shape declares a pure virtual area().
hardNot startedSolve
292
Polymorphic Salary CalculationThe base class Employee has a totalPay() method that returns baseSalary plus the result of the VIRTUAL method bonus() (which returns 0 by default).
hardNot startedSolve
450
Diamond Problem With Virtual InheritanceWhen two classes inherit from the same base and a fourth class inherits from both, you get the "diamond problem": two copies of the base and ambiguous member access.
hardNot startedSolve
451
Dynamic Cast to a Derived Typedynamic_cast safely converts a base pointer to a derived pointer at RUNTIME: it returns a valid pointer if the object really is that type, or nullptr if it is not.
hardNot startedSolve
452
Covariant Return Types With CloneAn overriding virtual function may return a pointer to a MORE derived type than the base declares.
hardNot startedSolve
453
Pure Virtual Function With a DefinitionA pure virtual function (= 0) makes its class abstract, but it may STILL have a body defined out of the class.
hardNot startedSolve