我想重載我的操作符它真的只是一個類,它包含算術函數和一個數組變量序列。二進制'*':沒有找到全局運算符,它需要類型'統計'(或沒有可接受的轉換)
但是當我我的過載(*)乘法算我得到這個錯誤:
binary '*' : no global operator found which takes type 'statistician'
(or there is no acceptable conversion)
這發生在我的代碼試圖做的事:s = 2*u;
在main.cpp中
其中s和u是統計學課程。
統計學家=我的課
(statistician.h)
class statistician
{
... other functions & variables...
const statistician statistician::operator*(const statistician &other) const;
..... more overloads...
};
任何幫助將是真棒謝謝!