Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact

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 C234
Further C++ Object Oriented features
Exercises, examples and other material relating to training module C234. This topic is presented on public courses Learning to program in C and C++, C++ for C Programmers, C and C++ Programming, Learning to program in C and C++, C and C++ Programming

Further advanced features of Object Orientation in C++. At first, you may not feel that you would like to redefine the "+" operator - but as you get used to the idea, you'll like it. Imagine doing matrix multiplication using the * operator, or adding two cuboid volumes using the + operator and having it work as easily as that.
Articles and tips on this subjectupdated
4559When do I use the this keyword in C++?
Question: When do I use the this keyword in C++? Answer: When I expliciy need (or want) to refer to a member variable or object within the current object. Example:    class Transport{       public:          Transport(int);          int ...
4377Designing a base class and subclasses, and their extension, in C++
My first technical post for 2015 - looking back at some of last year's new C++ examples. Oh - OK - I'm writing this on 1st January and these examples were written and uploaded yesterday, so they're nothing like as old as it sounds. On Monday and Tuesday, I wrote classes from scratch and looked at basic ...
4366Changing what operators do on objects - a comparison across different programming languages
In Object Oriented languages, you used named pieces of code known as methods to perform an operation on a variable - for example you might write   weeklist.extend(weekend) to take a list of (something) for a week and add a list relating to weekend onto the end of it. Sometimes, the method ...
3982Using a vector within an object - C++
Background - why? It's very common in program to have a whole lot of objects which when collected together make another object of a different type. That different object isn't going to be part of the same inheritance tree either - it's simply an associated object type / class. That's a bit of an abstact ...
3509Operator Overloading, Exceptions, Pointers, References and Templates in C++ - new examples from our courses
I've added three new C++ examples to our library following on from last week's C++ course. Each of them is one step beyond "hello world" with regard to the particular feature it's showing, but isn't so advanced and showing so many options that it confuses the newcomer - at least that's the theory. ...
3430Sigils - the characters on the start of variable names in Perl, Ruby and Fortran
A sigil (from Latin sigillum "seal") is a symbol created for a specific magical purpose. A sigil is usually made up of a complex combination of several specific symbols or geometric figures, each with a specific meaning or intent. In computer programming, a sigil is a special symbol attached to a variable ...
3238Bradshaw, Ben and Bill. And some C and C++ pointers and references too.
I have a scarse original of the January, 1960 edition of Bradshaw's guide. Bill and Ben are on my course, and they both want to take a look at it. So I take a perfect photocopy of it, and I pass that copy to Bill with the original handed, with great reverance, to Ben. Bill and Ben both spend some time ...
3124C++ - putting the language elements together into a program
On the final day of the C++ course yesterday, I demonstrated a number of advanced features and pulled together various strands that we had been learning through the week. At one level, each feature of the language can be explained and taught, but there's a further level that's need to show how they ...
3069Strings, Garbage Collection and Variable Scope in C++
In C, you'll handle strings as arrays of chars (type char *) and that does work - but with grumbles from the compiler about deprecation - in C++. The more modern (or shall we say "more OO") approach is to handle strings as objects - and those will be objects of type string, with headers loaded via   #include ...
3057Lots of things to do with and within a C++ class
I've added a build up example - written during the current C to C++ conversion bootcamp - to our Further C++ OO Features module. First step shows a simple class and test harness. Second step adds a comparison of heap or stack objects, overloading of methods, static methods, more character handling, ...
2849What are C++ references? Why use them?
C++ References let you give variables alternative names. For example, if you write   int & jones = flossie; then "jones" becomes an alternative name for flossie in the current scope. If you assign something new to jones, you're not going to make the variable into an alternative name for ...
2717The Multiple Inheritance Conundrum, interfaces and mixins
Should an OO programming language support "multiple inheritance"? Let's define multiple inheritance first - starting from simple (single?) inheritance. (Single) Inheritance. I don't want to have to define each type of thing ("class of object") from scratch, so I'll define once class as being based ...
2673Multiple Inheritance in C++ - a complete example
C++ and some other OO languages support multiple inheritance ... Java and some others do not, and it's often argued that multiple inheritance is an unnecessary complication. That may be the case in some languages, but certainly in Perl 5 it is necessary to have it to make use of eome of the modules ...
2576What does const mean? C and C++
If you declare a variable to be a const, you're telling the compiler that it's a read-only variable and that it won't be changed throughout its existance. A values that's passed in as a parameter to a function, for example, will be left alone until the function exits. That does not stop you from deriving ...
2005Variables and pointers and references - C and C++
If I have a variable called "weight" that contains a float, I can use and set its value by using that name. Pointers If - in C or in C++ - I declare a variable to be a pointer then that variable may contain a memory address ... I use a * in my type declaration, and then I use & in my assignment: float ...
2004Variable Scope in C++
In C++, a variable is 'scoped' to the block in which it is declared. In other words, it exists from the point at which you tell the compiler what type of value it contains through to the close brace at that matches the open brace preceeding that declaration. In the most frequent use, this means that ...
801Simple polymorphism example - C++
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 on each object and have the run time environment select which particular piece of code is to be run each time around a loop (experienced OO programmers ...
1819Calling base class constructors
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, and the newly defined class ("subclass" or "extended class") takes the initial ("base") class as it starting point. In your code for your base class, ...
802undefined reference to typeinfo - C++ error message
There are some compiler and loader error messages that shout obviously as to their cause, but there are others that simply don't give the new user much of an indication as to what's really wrong. And most of those I get to know pretty quickly, so that I can whip around a room during a course, making ...
1159It can take more that one plus one to get two.
I was running a C++ course yesterday (yes, a Saturday!) and among the topics we covered was the overloading of operators. In languages such as C++ and Python, you can re-define what operators such as "+" do when you add objects together, and the course example I used was adding two enclosing cubes - ...
831Comparison of Object Oriented Philosophy - Python, Java, C++, Perl
There are two different philosophies that have been adopted by the authors of Object Oriented languages. The first approach is to set the thing up in such a way that a programmer who uses someone else's code as the basis for his isn't going to be trusted to use that other person's code in a sensible ...
Examples from our training material
PMdemo   Polymorphism - complete example
Xmas.cpp   Vector, Multiple Inheritance, virtual, Polymorphism, Factory
act_01.cpp   Simple C++ demo - class - interface and test program
act_02.cpp   Second C++ demo - heap v stack, char handling, this, static
act_03.cpp   Object Extras. Vector, delete, factory, destructor, etc
alias.cpp   Direct, Pointer and Reference access to variables
bighotels.cpp   Comparing objects
coffee.cpp   Overriding add, multiply and << for print
compare.cpp   Comparatives - heavy, heavier, heaviest
cube.cpp   Operator overloading
erandest.cpp   costly, costly, costliest - object comparison
first.cpp   OO Buildup in C++ - starter
hotel.cpp   Class member code
hotel.inc   Class descriptor
makefile   Compile / Load instructions for examples in this module
melkshamhotel.cpp   Derived class member code
melkshamhotel.inc   include file to define melkshamhotel
overload_add.cpp   Operator (+) and to_string overloading, C++
pet.cpp   multiple constructors, default parameters
r2.cpp   References and Pointers for each array member
refdemo.cpp   References and Pointers
refs.cpp   Direct, pointer and reference comparison
regionhotel.cpp   Derived class member code
regionhotel.inc   include file to define melkshamhotel
sixth.cpp   Interitance, Base Classes, Overloading of methods, etc - C++ course
sixtyfive.cpp   Direct, reference and pointer access to variables
tinyref.cpp   References - description and sample 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 [here].
Topics covered in this module
Virtual functions.
Inline functions.
Friend funcions.
Dynamic Objects.
Overloading functions and operators.
Multiple constructors and default arguments.
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 Ruby, Lua, 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.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2017: 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

PAGE: http://www.wellho.net/resources/C234.html • PAGE BUILT: Mon Feb 8 18:55:24 2016 • BUILD SYSTEM: WomanWithCat