Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Complete teaching example - C++, inheritance, polymorphism

On yesterday's C++ course, I provided a final example which illustrated polymorphism, and showed how even the simple example was best written, split, ito no less that seven source files.

1. The main C++ source code - for my example, a simple demo test harness
See http://www.wellho.net/resources/ex.php4?item=c051/further.cpp

2. The C++ source code of the first class that my example used
See http://www.wellho.net/resources/ex.php4?item=c051/starredhotel.cpp

3. The C++ source code of the second class that my example used
See http://www.wellho.net/resources/ex.php4?item=c051/selfhotel.cpp

4. The C++ source code of the base class from which my two sample classes were derived.
See http://www.wellho.net/resources/ex.php4?item=c051/g_hotel.cpp

Because I need to include function / method prototypes into various files so that the comiler can check that calls are valid in isolation from the separate compiles, I have also provided separate header files. In theory it is possible to include these within the four source files above directly, but that is a TERRIBLE practice and you should load them through #includes ...

5. The header file defining the methods in the first used class
See http://www.wellho.net/resources/ex.php4?item=c051/starredhotel.h

6. The header file defining the methods in the second used class
See http://www.wellho.net/resources/ex.php4?item=c051/selfhotel.h

7. The header file defining the methods in the base class
See http://www.wellho.net/resources/ex.php4?item=c051/g_hotel.h

In essence, C++ is mostly about adding object orientation to C (thus meking it a completely different kettle of fish!), so I have loaded each of the course files above onto our web site so that you can see the complete example under the category "C++ in general". They illustrate a very large range of features - inheritance, overloading, polymorphism, virtual functions, etc ... all of which I'll explain to you on our C++ courses - in fact, this set of examples was written on the C++ course which ended yesterday, where I showed the delegate how we design and write object oriented programs in C++ from scratch.

We offer three public courses

Learning to program in C++ - 5 days, for delegates who have never programmed before in any programming language, or have done so VERY little.
See http://www.wellho.net/course/cffull.html

C and C++ programming - 4 days, for delegates who have programmed before, but not in C (on which C++ is based)
See http://www.wellho.net/course/cafull.html

C++ Programming - 2 days, for experienced C programmers who need to add the extras of C++ (and learn which parts of C they can gently retire!)
See http://www.wellho.net/course/cpfull.html
(written 2010-01-15 09:07:59)

 
Associated topics are indexed under
C051 - C and C based languages - C++ - General
  [2851] Further C++ material - view new or old - (2010-07-04)
  [2763] Our C and C++ training course are on Open Source platforms - (2010-05-13)
  [2536] All the Cs ... and Java too - (2009-12-13)
  [2504] Learning to program in ... - (2009-11-15)
  [2370] C++, Python, and other training - do we use an IDE - (2009-08-21)

C233 - C and C based languages - OO in C++ - beyond the basics
  [2845] Objects and Inheritance in C++ - an easy start - (2010-07-01)
  [1819] Calling base class constructors - (2008-10-03)
  [1674] What a lot of files! (C++ / Polymorphism demo) - (2008-06-12)
  [1572] C - structs and unions, C++ classes and polymorphism - (2008-03-13)
  [1217] What are factory and singleton classes? - (2007-06-04)
  [925] C++ - just beyond the basics. More you can do - (2006-11-14)
  [831] Comparison of Object Oriented Philosophy - Python, Java, C++, Perl - (2006-08-13)
  [801] Simple polymorphism example - C++ - (2006-07-14)
  [798] References and Pointers in C++ - (2006-07-10)

C232 - C and C based languages - Defining and using classes in C++
  [2579] Creating, setting up and using objects in C++ - (2010-01-16)
  [2578] Where are your objects stored in C++? - (2010-01-16)
  [1925] Introduction to Object Oriented Programming - (2008-12-06)


Back to
What does const mean? C and C++
Previous and next
or
Horse's mouth home
Forward to
Where are your objects stored in C++?
Some other Articles
Snow scenes - and how snow effected our business
C course inspires new teaching examples
Complete teaching example - C++, inheritance, polymorphism
What does const mean? C and C++
Sharing variables between files of code in C - extern
Summary of Wiltshire Core Strategy responses
C Structs - what, how and why
The what and why of C pointers
2940 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

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: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho