看板 NTUEE107HW 關於我們 聯絡資訊
※ 引述《whitesheep1 (月兒天邊高高掛)》之銘言: : #include <iostream> : using std::cout; : using std::cin; : using std::endl; : class polynomial{ : public: : polynomial(int =10);//constructor : polynomial operator+(polynomial);//addition : polynomial operator-(polynomial);//substruction : polynomial operator*(polynomial);//mutiply : polynomial operator+=(polynomial); : polynomial operator*=(polynomial); : polynomial operator-=(polynomial); : void print(void); : private: : int size;//arraysize : int *ptr;//array : }; : polynomial polynomial::operator+(polynomial &a) : { : if (size>a.size) : for (int i=1; i<=size ;i++) : ptr[i]=ptr[i]+a.ptr[i]; : else : for (int i=1; i<=a.size ;i++) : ptr[i]=ptr[i]+a.ptr[i]; : return *this; : } : C:\Documents and Settings\莊皓翔\桌面\hw819.cpp(34) : error C2511: '+' : : overloaded member function 'class polynomial (class polynomial &)' not found in : 'polynomial' : C:\Documents and Settings\莊皓翔\桌面\hw819.cpp(6) : see declaration of : 'polynomial' : 不知道 哪裡錯了 誰幫幫我 謝謝^^ :是不是在function declaration中改成 : : polynomial operator+(polynomial & ); : : 才對? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.203.67.119
timrau:不是這樣的 推 140.112.18.105 12/31