Syntax
-----------
class A { // base class
int a;
public A() {...}
public void F() {...}
}
class B: A {// subclass (inherits from A, extends A)
int b;
public B() {...}
public void G() {...}
}
�B inherits aand F(), it adds band G()
-constructors are not inherited
-inherited methods can be overridden
�Single inheritance: a class can only inherit from one base class, but it can implement multiple interfaces.
�A class can only inherit from a class, not from a struct.�Structs cannot inherit from another type,
but they can implementmultiple interfaces.
�A class without explicit base class inherits from object.
No comments:
Post a Comment