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:它取决于你实例化的类型。 **显示代码** –