Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

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 C232
Defining and using classes in C++
Exercises, examples and other material relating to training module C232. 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

Background
How to set up your own classes of objects in C++, and how to use those objects and also objects that are available to you from elsewhwere. We also introduce access levels in this module.
Articles and tips on this subjectupdated
4565Allocation of memory for objects in C++ - Stack v Heap
In C++, memory is allocated to variables on a stack or on a heap. Allocated on the stack, the variable persists until the end of the block in which it's defined. Allocated on the heap, the memory containing the object persists until the end of your program, or until you delete the object. Stack memory ...
2015-10-31
 
4372Template / design pattern for C++ constructor and accessors
Would you believe I'm giving a C++ course on Monday, 29th December? If a customer wants a weekend or holiday time course, yes, we can arrange it! From this afternoon - a first example in C++ - [here]. I've defined the API to a class, the class itself and the first (test) program all in the one file ...
2014-12-30
 
4129Simple OO demonstration in C++, comparison to Python
From last week's quick introduction to C++ (a private course - half a day added on to the end of a C Programming course - an example of how C++ implements objects for a newcomer to C++ who's seen some Python. Firstly, in C++ you must predefine the API - the interface between the user and the class. ...
2013-07-15
 
3978Teaching OO - how to avoid lots of window switching early on
One of the major benefits of Object Oriented programming is the clear and sharp dividing lines it provides between the different sections of logic - where code dealing with one type of data is specified, written, stored and tested in different files to the code dealing with other types of data (or code ...
2013-01-19
 
3810Reading files, and using factories to create vectors of objects from the data in C++
On our C++ courses, we concentrate on objects and object design. But we also take a wider look at topics such as references and templates that go to making the complete language, with sections covering changes to things like file handling from the underlying C language. I've just added a new example ...
2012-08-11
 
3721Naming blocks of code, structures and Object Orientation - efficient coding in manageable chunks
Soon after you start to program, you'll learn that you want to re-use code. And that re-use will sometimes come in the form of loops, and at other times in the form of named blocks of code which you'll call up from multiple places in your program, or indeed from multiple programmers. • A good ...
2012-05-12
(longer)
3716Learning C++ - a design pattern for your first class
From today's C++ Course - a new, clear example of a design pattern for a simple class, its headers, and a test harness - [here]. When using an Object Oriented language, design patterns are really useful. Essentially, they're a known and standard way of combining the features of the language in a convenstional ...
2012-05-05
 
3250C++ - how we teach the language and the concepts behind the language
When I'm teaching an object oriented language such as C++, I like to write code and demonstrate from scratch to my class, getting them to 'feed' me with application data and information so that I can show them how programs are really developed using the OO approach - both in general, and in the specific ...
2011-04-17
 
2577Complete 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. ...
2010-10-30
 
2579Creating, setting up and using objects in C++
Early on this week's C++ programming course (including the C fundamentals), I wrote a new and short example that defined and used a class of objects of type "Hotel". Really, this initial example was very much shorter than any real program you would write and it used a very limited number of the facilities, ...
2010-01-16
 
2578Where are your objects stored in C++?
If you declare a variable to be of an object type in C++ (and potentially do so with parameters), you're going to be assigning memory for the variables that it includes on the stack - i.e. within memory that will be lost when you exit the closure (block of code - function - method) in which you are defining ...
2010-01-16
 
1925Introduction to Object Oriented Programming
"Object Oriented Programming" is a whole new philosophy for programmers who have been writing short scripts for years, and it can be quite frightening to learn with all these new buzzwords like "overriding", "encapsulation" and "polymorphism" creeping in. It's a beautiful concept and a lovely approach, ...
2008-12-10
(longer)
Examples from our training material
a2.cpp   Array of objects of different types
a3.cpp   Inherited methods - test program
afuncs.cpp   Class use with accessory functions
allin1.cpp   Class definition and use all in one file
book.cpp   Class implementation code - book
book.inc   Class interface - book
dayfour.cpp   Creating objects on the stack or heap
demo1.cpp   Base class and subclass method definition
demo1.h   Base class and subclass header definition
demo2.cpp   Further base and subclass definition
demo2.h   Further base and subclass header definition
demomake   makefile for module c232
g_main.cpp   Fundamental use of classes example - C++
hcd.cpp   Class description with accessor functions
hellosurvey.cpp   Template for your first OO classes
hmain.cpp   First class in C++
hotel.cpp   Class member code
hotel.inc   Class descriptor
makefile   Compile / Load instructions for examples in this module
melksham.cpp   Class use with accessor functions
mylib.cpp   Main application calling constructors and destructors
objects_bothways.cpp   stack v heap - object persistance
table.cpp   code - the internals of the Table class
table.h   Definition of API of a class
tabletest.cpp   A test harness for the Table class
template.cpp   Design Pattern for class definition and test
transport.cpp   Hello c++ world - define and use an object / Compare to Python
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
Defining classes through struct and class.
Member functions.
Constructors and Destructors.
Private, Protected and Public.
Exercise.
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., 2024: 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.info/resources/C232.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb