N
Nick
Is this possible:
class A
{
protected int n = 1;
}
class B: A
{
public void m2() { n = 2;}
}
class C: A
{
public int m3() { return n;}
}
class Test
{
B b = new B();
b.m2();
C c = new C();
c = b;
// this give me an error because C has turn into B
c.m3();
}
When working with class C, I want to use/inherit all work
done on class B. However, the code above will change C to
a B, which is not what I want because I still want to use
methods in C.
Thanks.
Nick
class A
{
protected int n = 1;
}
class B: A
{
public void m2() { n = 2;}
}
class C: A
{
public int m3() { return n;}
}
class Test
{
B b = new B();
b.m2();
C c = new C();
c = b;
// this give me an error because C has turn into B
c.m3();
}
When working with class C, I want to use/inherit all work
done on class B. However, the code above will change C to
a B, which is not what I want because I still want to use
methods in C.
Thanks.
Nick