I'm reading through A Complete Guide to Programming in C++ written by Ulla Kirch-Prinz and Peter Prinz, published by Jones & Bartlett. In it, there is an example of a class (page 246) with what I think is a major problem--not in that it is an error but something I've heard you are never supposed to do:
// account.h
// Defining the class Account.
// ---------------------------------------------------
#ifndef _ACCOUNT_ // Avoid multiple inclusions.
#define _ACCOUNT_
#include <iostream>
#include <string>
using namespace std;
class Account
{
private: // Sheltered members:
string name; // Account holder
unsigned long nr; // Account number
double balance; // Account balance
public: //Public interface:
bool init( const string&, unsigned long, double);
void display();
};
#endif // _ACCOUNT_
The include guard's macro begins and ends with underscores. From what I've been told, underscores are reserved for use by the Standard Library, the operating system, and the compiler and unless you are creating an operating system or compiler, there's pretty much no reason to ever use it.
I get that this is just an example but for the intents and purposes of teaching people good programming habits, it still seems like they messed up badly with this one. Having said that, I'm still pretty new to this so I could be wrong and it is appropriate.