#include <iostream.h>
class A {
public: int a;
void aa(){
cout << "A::aa(), a=" << a << endl; }
};
class B: public A {
public: int a;
void aa() {
cout << "B::aa(), a=" << a << endl; }
};
class C: public B {
public: int a;
void aa(){
cout << "C::aa(), a=" << a << endl; }
void ShowAll();
};
void main()
{
C c;
c.a = 30;//równoważne c.C::a = 30;
c.aa();
c.B::a = 20;
c.A::a = 10;
c.B::aa();
c.A::aa();
c.ShowAll();
}
void C::ShowAll(){
cout << "A:a = " << A::a << " B:a = "
<< B::a << " C:a = " << a << endl; }
import java.lang.*;
class A {
public int a;
public static void aa()
{ System.out.println("A.aa"); }
}
class B extends A {
public int a;
public static void aa()
{ System.out.println("B.aa"); }
}
class C extends B {
public int a;
public static void aa()
{ System.out.println("C.aa"); }
public void ShowAll()
{ System.out.println("A.a=" + A.a +
", B.a=" + super.a + ", C.a=" + a); }
}
public class Przykr {
public static void main(String args[])
{
C c = new C();
c.a = 30;
c.ShowAll();
((B)c).a = 20;
((A)c).a = 10;
c.ShowAll();
c.aa();
((B)c).aa();
((A)c).aa();
}}