Main Content
Objects and Inheritance in C++ - an easy start Archive - Originally posted on "The Horse's Mouth" - 2010-07-01 16:58:49 - Graham Ellis
We can end up with a lot of files when we do even a simple C++ example to show inheritance - a file for the main program, a file each for the base class and subclass, and a header file for the prototypes for each of the base class and subclass too.
So it's much easier to do it all as one file - but suggest to the delegates that the code should be split across multiple files once it's functioning. And I have added an example - [here] - to our web site to show the fundamentals all in one, to give newcomers to objects and inheritance in C++ an easy start.
Some other articles
C233 - OO in C++ - beyond the basics Variables, Pointers and References - C and C++ When do I use the this keyword in C++? Designing a base class and subclasses, and their extension, in C++ Final examples for 2014 - and a look at our 2015 training course options Object factories in C++, Python, PHP and Perl Extended and Associated objects - what is the difference - C++ example Associated Classes - using objects of one class within another Destructor methods in C++ - a primer C++ - objects that are based on other objects, saving coding and adding robustness C and C++ - preprocess, compile, load, run - what each step is for Private and Public - and things between C++ - putting the language elements together into a program C++ objects - some short, single file demonstrations C++ - a complete example with polymorphism, and how to split it into project files This article 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++ C231 - Introduction to C++ Left shift operator on an output stream object - C++ Hello World in C++ - a first program, with the process explained Moving from C to C++ - Structured to Object Oriented - a lesson for engineers C++ - how we teach the language and the concepts behind the language Strings, Garbage Collection and Variable Scope in C++ Make - automating the commands for building and installing Getting your C++ program to run This article When should I use OO techniques? Variable Scope in C++ C++ and Perl - why did they do it THAT way? Targetted Advertising Choosing a theme Programming languages - a comparison