Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Operator 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. See what you think in practise ;-)

An example in which I've redefined the operators "+" and "*" for a class, so that we can combine "mean time between failure / service" objects. And the example also overrides how the << method on an output file stream works for objects of this type so that we can output them in a default format. See [source].

How to define, throw and catch exceptions in C++. Exceptions are an excellent failsafe way of trapping problems - as opposed to checking for errors which isn't intrinsically failsafe because you need to know what all the possible errors are ahead of time. See [source].

References and Pointers can both be used to (in effect) pass data into a function / method so that it's read/write - i.e. in such a way that the original data in the calling method will be changed to reflect changes made via the passed in variable. This example shows a (default) call-by-value function which doesn't work as you would wish - it swaps over copies of variables leaving the original untouched. But it then showx how to do it with references and with pointers, and also how you can do it with a template so that my "swapper" routine used is generic across all appropriate data types. [source].
(written 2011-11-06)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
C238 - C and C based languages - Templates
  [1478] Some new C programming examples - files, structs, unions etc - (2007-12-19)
  [3245] Collections in C and C++ - arrays, vectors and heap memory blocks - (2011-04-12)
  [3252] C++ - unknown array size, unknown object type. Help! - (2011-04-17)
  [3388] Templates in C++ - defining a family pattern of methods / functions - (2011-08-12)
  [3810] Reading files, and using factories to create vectors of objects from the data in C++ - (2012-07-21)
  [3982] Using a vector within an object - C++ - (2013-01-19)

C236 - C and C based languages - Exceptions
  [799] The case for exceptions - (2006-07-11)
  [1875] What are exceptions - Python based answer - (2008-11-08)
  [2622] Handling unusual and error conditions - exceptions - (2010-02-03)
  [3068] Throwing your own exception in C++, and catching it - (2010-11-24)

C234 - C and C based languages - Further C++ Object Oriented features
  [801] Simple polymorphism example - C++ - (2006-07-14)
  [802] undefined reference to typeinfo - C++ error message - (2006-07-15)
  [831] Comparison of Object Oriented Philosophy - Python, Java, C++, Perl - (2006-08-13)
  [1159] It can take more that one plus one to get two. - (2007-04-22)
  [1819] Calling base class constructors - (2008-10-03)
  [2004] Variable Scope in C++ - (2009-01-22)
  [2005] Variables and pointers and references - C and C++ - (2009-01-23)
  [2576] What does const mean? C and C++ - (2010-01-15)
  [2673] Multiple Inheritance in C++ - a complete example - (2010-03-12)
  [2717] The Multiple Inheritance Conundrum, interfaces and mixins - (2010-04-11)
  [2849] What are C++ references? Why use them? - (2010-07-02)
  [3057] Lots of things to do with and within a C++ class - (2010-11-16)
  [3069] Strings, Garbage Collection and Variable Scope in C++ - (2010-11-25)
  [3124] C++ - putting the language elements together into a program - (2011-01-08)
  [3238] Bradshaw, Ben and Bill. And some C and C++ pointers and references too. - (2011-04-09)
  [3430] Sigils - the characters on the start of variable names in Perl, Ruby and Fortran - (2011-09-10)
  [4366] Changing what operators do on objects - a comparison across different programming languages - (2014-12-26)
  [4377] Designing a base class and subclasses, and their extension, in C++ - (2015-01-01)
  [4559] When do I use the this keyword in C++? - (2015-10-29)


Back to
Destructor methods in C++ - a primer
Previous and next
or
Horse's mouth home
Forward to
The skull above the door in Melksham Town Hall
Some other Articles
Olympic Torch - dates and places in Wiltshire in 2012
A colleague and friend who changed my life
Melksham has a heart - have your picture taken and support the defibrillator appeal
The skull above the door in Melksham Town Hall
Operator Overloading, Exceptions, Pointers, References and Templates in C++ - new examples from our courses
Destructor methods in C++ - a primer
Melksham Forward - meeting summary and pictures
Cold call contacts - preference services and turning off spam sales approaches
Well House Manor - Winter Warmers - Open 7 days a week, 11 to 5 ++
Coaches from Trowbridge and Melksham to London
4759 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, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 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., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/3509_Ope ... urses.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb