fork download
  1. #if !defined(__VECTORCPX_H)
  2. #define __VECTORCPX_H 1
  3.  
  4. #include <cstdlib>
  5. #include <cstdio>
  6. #include <climits>
  7. #include <limits>
  8. #include <iostream>
  9. #include <fstream>
  10.  
  11. using namespace std;
  12.  
  13. class VectorCpx; //在定義Complex時,這個class還不知道什麼叫做VectorCpx,因此得先加這行"forward declaration"告訴他
  14. class Complex
  15. {
  16. private:
  17. double mReal, mImag;
  18.  
  19. public:
  20. Complex(double _real = 0, double _imag = 0);
  21. const double& real() const;
  22. const double& imag() const;
  23. void real(double value);
  24. void imag(double value);
  25. Complex operator+(const Complex& cpx) const;
  26. Complex operator-(const Complex& cpx) const;
  27. Complex operator*(const Complex& cpx) const;
  28. VectorCpx operator*(const VectorCpx& vc) const;
  29. Complex operator/(const Complex& cpx) const;
  30. };
  31.  
  32. ostream& operator<<(ostream& ostr, const Complex& cp);
  33.  
  34. //////////////////////////////////////////////////////////////
  35.  
  36. class VectorCpx
  37. {
  38. private:
  39. Complex *pCpx;
  40. unsigned mSize, mCapacity;
  41.  
  42. public:
  43. VectorCpx(); //default constructor
  44. VectorCpx(unsigned, const Complex&); //constructor
  45. VectorCpx(unsigned); //constructor
  46. VectorCpx(const VectorCpx&); //copy constructor
  47. ~VectorCpx(); //destructor
  48.  
  49. VectorCpx& push_back(const Complex&);
  50. VectorCpx& resize(unsigned);
  51. VectorCpx& resize(unsigned, const Complex&);
  52. unsigned size() const;
  53. unsigned capacity() const;
  54. //Complex output(int) const;
  55.  
  56. Complex operator*(const VectorCpx& vc) const;
  57. VectorCpx operator*(const Complex& cpx) const;
  58. Complex& operator[](const int& place) const; //這裡的Complex型態後面必須要加上"&",因為回傳的值必須能拿到Complex class裡修改
  59. VectorCpx operator=(const VectorCpx vc) const;
  60. };
  61.  
  62. ostream& operator<<(ostream& ostr, const VectorCpx vc);
  63.  
  64. #endif
  65.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i486-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty