36 lines
978 B
C++
36 lines
978 B
C++
|
|
#ifndef EXAMPLE05_COMPLEX_H
|
|
#define EXAMPLE05_COMPLEX_H
|
|
|
|
class Complex {
|
|
private:
|
|
double real, imag;
|
|
static int counter; // class variable
|
|
//static const int counter1; // constant class variable
|
|
public:
|
|
Complex(); // default constructor
|
|
Complex(double r, double i = 0); // conversion constructor
|
|
Complex(const Complex& c); // copy constructor
|
|
~Complex(); // destructor
|
|
void print() const;
|
|
Complex plus(const Complex& c) const;
|
|
|
|
//static int getCounter();
|
|
|
|
static int getCounter() { // class method
|
|
return counter;
|
|
//return real; // ERROR
|
|
//return counter++; // OK
|
|
//return this->counter; // ERROR
|
|
}
|
|
/*
|
|
//static int getCounter1() const { // const is not allowed for class methods
|
|
static int getCounter1() { // class method
|
|
return counter1;
|
|
//return counter1++;
|
|
}
|
|
*/
|
|
};
|
|
|
|
#endif //EXAMPLE05_COMPLEX_H
|