May 2002
Beginner
320 pages
6h 18m
English
There is one special form of constructor with arguments: the copy constructor (see Listing 17.8).
This is used so that you can create an object whose state is exactly the same as the state of another object of the same class.
1: class aSAMSAccumulator
2: {
3: private:
4:
5: float myAccumulator;
6:
7: public:
8:
9: enum anOperator
{add,subtract,multiply,divide,query,reset} ;
10:
11: aSAMSAccumulator(void);
12: aSAMSAccumulator(float theInitialAccumulatorValue);
*13: aSAMSAccumulator
(aSAMSAccumulator theOtherAccumulator);
14:
15: virtual ~aSAMSAccumulator(void);
16:
17: void Accumulate
(char theOperator,float theOperand = 0);
18: } ;
|
aSAMSAccumulator ...
Read now
Unlock full access