#if !defined(__VECTORCPX_H)
#define __VECTORCPX_H 1
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <limits>
#include <iostream>
#include <fstream>
using namespace std;
class VectorCpx; //在定義Complex時,這個class還不知道什麼叫做VectorCpx,因此得先加這行"forward declaration"告訴他
class Complex
{
private:
double mReal, mImag;
public:
Complex(double _real = 0, double _imag = 0);
const double& real() const;
const double& imag() const;
void real(double value);
void imag(double value);
Complex operator+(const Complex& cpx) const;
Complex operator-(const Complex& cpx) const;
Complex operator*(const Complex& cpx) const;
VectorCpx operator*(const VectorCpx& vc) const;
Complex operator/(const Complex& cpx) const;
};
ostream& operator<<(ostream& ostr, const Complex& cp);
//////////////////////////////////////////////////////////////
class VectorCpx
{
private:
Complex *pCpx;
unsigned mSize, mCapacity;
public:
VectorCpx(); //default constructor
VectorCpx(unsigned, const Complex&); //constructor
VectorCpx(unsigned); //constructor
VectorCpx(const VectorCpx&); //copy constructor
~VectorCpx(); //destructor
VectorCpx& push_back(const Complex&);
VectorCpx& resize(unsigned);
VectorCpx& resize(unsigned, const Complex&);
unsigned size() const;
unsigned capacity() const;
//Complex output(int) const;
Complex operator*(const VectorCpx& vc) const;
VectorCpx operator*(const Complex& cpx) const;
Complex& operator[](const int& place) const; //這裡的Complex型態後面必須要加上"&",因為回傳的值必須能拿到Complex class裡修改
VectorCpx operator=(const VectorCpx vc) const;
};
ostream& operator<<(ostream& ostr, const VectorCpx vc);
#endif