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); //<----this
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;
};
VectorCpx* VectorCpx::resize(unsigned place) //<----this
{
VectorCpx* newVec=new VectorCpx(place, Complex(0.0,2.0)); //<----this
delete[] pCpx;
return newVec;
}
v1=v2.resize(10); //<----this
Y2xhc3MgVmVjdG9yQ3B4CnsKICAgIHByaXZhdGU6CgkJQ29tcGxleCAqcENweDsKCQl1bnNpZ25lZCBtU2l6ZSwgbUNhcGFjaXR5OwoKCXB1YmxpYzoKCQlWZWN0b3JDcHgoKTsJLy9kZWZhdWx0IGNvbnN0cnVjdG9yCgkJVmVjdG9yQ3B4KHVuc2lnbmVkLCBjb25zdCBDb21wbGV4Jik7CS8vY29uc3RydWN0b3IKCQlWZWN0b3JDcHgodW5zaWduZWQpOwkvL2NvbnN0cnVjdG9yCgkJVmVjdG9yQ3B4KGNvbnN0IFZlY3RvckNweCYpOyAvL2NvcHkgY29uc3RydWN0b3IKCQl+VmVjdG9yQ3B4KCk7CS8vZGVzdHJ1Y3RvcgoKCQlWZWN0b3JDcHgmIHB1c2hfYmFjayhjb25zdCBDb21wbGV4Jik7CgkJVmVjdG9yQ3B4KiByZXNpemUodW5zaWduZWQpOyAgLy88LS0tLXRoaXMKCQlWZWN0b3JDcHgmIHJlc2l6ZSh1bnNpZ25lZCwgY29uc3QgQ29tcGxleCYpOwoJCXVuc2lnbmVkIHNpemUoK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