Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact

New telephone system - working a day early.
01225 708225 (phone) and 01225 899360 (fax) again ;-)
Upcoming U.K. C / C++ courses ...
Learning to program in C++
C and C++ programming
C++ Programming

Learning to program in C
C Programming

Background
If you want to define one object that's similar (but not identical) in structure and behaviour to another, you do so through inheritance. If you then have an array of similar objects, you can have C++ decide which particular behavious to use on each element in turn and this is known as polymorphism. In C++, you can define a type of object that inherits its behaviour from seveal others if you wish, and you can group toghether a whole lot of similar types of objects into modules - both of these are more advanced facilities that we cover in this module.
Tips and short articles on this subject
Objects and Inheritance in C++ - an easy start
Complete teaching example - C++, inheritance, polymorphism
Calling base class constructors
What a lot of files! (C++ / Polymorphism demo)
C - structs and unions, C++ classes and polymorphism
What are factory and singleton classes?
C++ - just beyond the basics. More you can do
Comparison of Object Oriented Philosophy - Python, Java, C++, Perl
Simple polymorphism example - C++
References and Pointers in C++
Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
C and C based languages module C233
OO in C++ - beyond the basics
Exercises, examples and other material relating to training module C233. This topic is presented on public courses Learning to program in C++, C++ for C Programmers, C and C++ Programming

Learning to program in C++ - a conversion course for programmers in other languages This intensive course teaches the C languages, and the C++ language ...
http://www.wellho.net/course/cffull.html  [course]
C and C++ Programming - a conversion course for programmers in other languages This intensive course teaches the C languages, and the C++ language which ...
http://www.wellho.net/course/cafull.html  [course]
C++ for C Programmers - Learn Object Orientation and the C++ language This course takes experienced C programmers and teaches them the extra skills of ...
http://www.wellho.net/course/cpfull.html  [course]
#include #include "melkshamhotel.inc" #include "regionhotel.inc" /* See also: hotel.cpp melkshamhotel.cpp hotel.inc melkshamhotel.inc makefile */ ...
http://www.wellho.net/resources/ex.php4?item=c233/accom4.cpp  [code sample]
In all object oriented languages, you have a facility called inheritance where you can define one type of thing ("class of object") based on another, ...
http://www.wellho.net/mouth/1819_Cal ... ctors.html  [short article]
I've been preparing some new C++ notes, in particular showing how you can create an array of objects of different derived types, and then call methods ...
http://www.wellho.net/mouth/801_Simp ... le-C-.html  [short article]
Do you find some of the OO terminolgy baffling? Once you've learnt about constructors and methods, inheritance, overloading and polymorphism and statics, ...
http://www.wellho.net/mouth/1217_Wha ... sses-.html  [short article]

If you want to define one object that's similar (but not identical) in structure and behaviour to another, you do so through inheritance. If you then have an array of similar objects, you can have C++ decide which particular behavious to use on each element in turn and this is known as polymorphism. In C++, you can define a type of object that inherits its behaviour from seveal others if you wish, and you can group toghether a whole lot of similar types of objects into modules - both of these are more advanced facilities that we cover in this module.

This topic is presented on public courses Learning to program in C++, C++ for C Programmers, C and C++ Programming

Examples from our training material
accom2.cpp   Class storing strings within an object
accom3.cpp   An array of objects
accom4.cpp   An array of objects
accomchooser.cpp   Class using classes and derived classes with inheritance
allinone.cpp.ex   Inheritance and Polymorphism example (all in 1 file)
beasts.cpp   Definition of polymorphic class methods
beasts.h   Definition of polymorphic class headers
hotel.cpp   Class member code
hotel.inc   Class descriptor
loader   Complete first Polymorphism example
makefile   Compile / Load instructions for examples in this module
melkshamhotel.cpp   Derived class member code
melkshamhotel.inc   include file to define melkshamhotel
midi.cpp   Inheriting a Constructor
regionhotel.cpp   Derived class member code
regionhotel.inc   include file to define region hotel
testh.cpp   First denmo of polymorphism
testh2.cpp   Demo of polymorphism across an array
tinin.cpp   base class, extended class, test code
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from http://www.training-notes.co.uk.
Topics covered in this module
Deriving one class from another - Inheritance.
Inheritance and access control.
Packaging classes into modules.
Extending Classes.
Multiple inheritance.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre. Also available is the Opentalk Forum for discussion of technical questions.


You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2010: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 0800 043 8225 or 01225 708225 • FAX: 01225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho