October 1997
Intermediate to advanced
800 pages
20h 48m
English
Let's see how to use namespaces (page 132) with classes. The following header file defines a namespace for our Roman class (see Listing 4.9 on page 201).
#ifndef ROMANH
#define ROMANH
// Roman.h - Roman class
namespace Anderson_Software_Group {
const int Roman_max = 20;
class Roman {
private:
int value; // decimal value
char s[Roman_max]; // Roman String
void convert_Roman(); // convert to Roman string
public:
// Constructors
Roman(int n = 1) { value = n; convert_Roman(); }
// Member Functions
const char *getroman() const { return s; }
int getnum() const { return value; }
};
}
#endif
|
Namespace Anderson_Software_Group includes a constant ...