[ create a new paste ] login | about

Link: http://codepad.org/xRhc5ig4    [ raw code | output | fork ]

C++, pasted on Jan 16:
#include <stdio.h>

class Grandparent
{
protected:
    void DoSomething( int number )
    {
       printf("Grand: %d\n", number);
    }
};

class Parent : protected Grandparent
{
protected:
    void DoSomething( int number )
    {
       printf("Parent: %d\n", number);
    }
};

class Child : Parent
{
public:
    void DoSomething()
    {
        Grandparent::DoSomething( 10 ); //Now it works
        Parent::DoSomething( 10 ); // Now it works.
    }
};

int main()
{
  Child c;
  c.DoSomething();
  return 0;
}


Output:
1
2
Grand: 10
Parent: 10


Create a new paste based on this one


Comments: