fork download
  1. class VectorCpx
  2. {
  3. private:
  4. Complex *pCpx;
  5. unsigned mSize, mCapacity;
  6.  
  7. public:
  8. VectorCpx(); //default constructor
  9. VectorCpx(unsigned, const Complex&); //constructor
  10. VectorCpx(unsigned); //constructor
  11. VectorCpx(const VectorCpx&); //copy constructor
  12. ~VectorCpx(); //destructor
  13.  
  14. VectorCpx& push_back(const Complex&);
  15. VectorCpx* resize(unsigned); //<----this
  16. VectorCpx& resize(unsigned, const Complex&);
  17. unsigned size() const;
  18. unsigned capacity() const;
  19. //Complex output(int) const;
  20.  
  21. Complex operator*(const VectorCpx& vc) const;
  22. VectorCpx operator*(const Complex& cpx) const;
  23. Complex& operator[](const int& place) const; //這裡的Complex型態後面必須要加上"&",因為回傳的值必須能拿到Complex class裡修改
  24. VectorCpx operator=(const VectorCpx vc) const;
  25. };
  26.  
  27.  
  28.  
  29. VectorCpx* VectorCpx::resize(unsigned place) //<----this
  30. {
  31. VectorCpx* newVec=new VectorCpx(place, Complex(0.0,2.0)); //<----this
  32. delete[] pCpx;
  33. return newVec;
  34. }
  35.  
  36.  
  37. v1=v2.resize(10); //<----this
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty