Further C++ material - view new or old
Archive - Originally posted on "The Horse's Mouth" - 2010-07-04 05:55:45 - Graham EllisI've taken out the old header <iostream.h> and replaced it by the current <iostream>. I've adding in using namespace std; where I've need to, in order to allow me access to cin and cout without a need to prefix then with std:: under the new header file (and to save me loads of errors at load time when other standard stuff is loaded!). And I've commented out the supressions of deprecated warnings from my makefile - # COPTS = -Wno-deprecated
I've taken the opportunity to add in to many of the main programs ... adding samples of how they compile and run, so that you can see what the programs do. Nothing to do with the way they work - everything to do with making them better examples when delegates come back and look and see how programs on their courses worked.
An update log for the basic defining and using classes in C++ module:
All in one first demo [here] replaces previous all in one demo [here].
Separating that into two files - the new main program [here] replaces the previous [here], but the included functions are unaltered [here]. I have added a few comments to the latter file, but as none of the executable statements nor C preprocessor directives has been changed, I have not provided a duplicate file on this site.
Use of a header (include) file and methods held in a separate file - main program of the demo [here] replaces previous version [here]. The include file [here] and functions [here] are unchanged.
An example with a specific contructor and destructor. The new class code is [here] and the previously used class code [here]. The new main program is [here] and the previous version [here]. Note that the only reason that I've had to change the class code at all is that I have added uses of cout in the constructor and destructor - as a demonstration so that the user / person running the code can see when they're called. You would certainly not want to do this in production code.
For completeness, the new makefile is [here] replacing the previous one [here].