template <class Type>
class Punct {
protected:
Type _x; // (1)
Type _y; // (1)
public:
Punct(Type = 0, Type = 0); // (2)
~Punct();
inline Type getX() const { return _x; }
inline Type getY() const { return _y; }
inline void setX(Type x) { _x = x; }
inline void setY(Type y) { _y = y; }
inline void moveBy(int x, int y) { _x = x; _y = y; }
friend std::istream &operator>>(std::istream&ins, Punct<Type>& A);
friend std::ostream &operator<<(std::ostream&outs, const Punct<Type>& A);
};
這是我得到的錯誤:場具有不完整的類型
(1) - 場具有不完全類型 '類型'
(2) - 沒有可行的從int類型轉換(有的加3.把參數傳給參數)
你能告訴我,我做錯了什麼?
該代碼沒有意義。 'Type'是一個類型,而不是一個變量,所以你不能給它賦值。你的意思是在你的構造函數中添加一個變量名。向我們展示'Type'的定義。 –
@EdS .:它不是賦值,它是初始化。 –
@Teodora:它取決於你實例化的類型。 **顯示代碼** –