C++ Multilevel Inheritance, Polymorphism


Suppose i have three classes A, B and C. class B inherits from class A and the inheritance is private whereas class C inherits from B and the inheritance is public. Now class A has a protected function which class C wants to access. So, what must be done in class B to make that protected function available to class C.

Here is the link to the code : http://pastebin.com/9E2sLZzj


Okay i got the solution This code fragment worked after inserting it into Class B.

int get(){
  return A::get();

Not sure what it does though

The "using" keyword makes a member of an inherited class visible, and resolvable, in the scope of its subclass. So, to make the privately-inherited member available to B's subclasses:

class A {


    void foo() {}

class B : private A {


    using A::foo;

class C : public B {

    void bar()

An item of type undefined (and it is a type) has no length property - only items of type string and array do. Therefore, as @redneb notes, extend your condition to check for a non-falsy value before checking length.

if (myVar && myVar.length) { ... }
By : Utkanos

This video can help you solving your question :)
By: admin