Object Oriented Programming using C#

(backadmin) #1
Object Oriented Programming using C#
Inheritance and Method Overriding

Each subclass can have its own constructor for specialised initialization but it must often invoke the behaviour of the base
constructor. It does this using the keyword base.

class MySubClass : MySuperClass
{
public MySubClass (sub-parameters) : base(super-parameters)
{
// other initialization
}

Usually some of the parameters passed to MySubClass will be initializer values for superclass instance variables, and these
will simply be passed on to the superclass constructor as parameters. In other words super-parameters will be some (or
all) of sub-parameters.

Shown below are two constructors, one for the Publication class and one for Book. The book constructor requires four
parameters three of which are immediately passed on to the base constructor to initialize its instance variables.

Stand out from the crowd
Designed for graduates with less than one year of full-time postgraduate work
experience, London Business School’s Masters in Management will expand your
thinking and provide you with the foundations for a successful career in business.
The programme is developed in consultation with recruiters to provide you with
the key skills that top employers demand. Through 11 months of full-time study,
you will gain the business knowledge and capabilities to increase your career
choices and stand out from the crowd.
Applications are now open for entry in September 2011.
For more information visit http://www.london.edu/mim/
email [email protected] or call +44 (0)20 7000 7573

Masters in Management

London Business School
Regent’s ParkLondon NW1 4SA
United KingdomTel +44 (0)20 7000 7573
Email [email protected]/mim/

Fast-track


your career


Please click the advert

Free download pdf