2015-10-20 101 views
0

它为什么显示错误?错误C2533:构造函数不允许返回类型

为什么我不能使用返回类型?

这是代码的一部分,其中存在错误

template <typename T> 
class Matrix 
{ 
public: 
    Matrix(int x = default_x, int y = default_y); 
    ~Matrix(); 
    Matrix<T> Matrix(const Matrix<T>& src); 
    int get_x_size() const { return x_size; } 
    int get_y_size() const { return y_size; } 
    T get_element(int x, int y) const; 
    void set_element(int x, int y, T elem); 
    // constant elements 
    static const int default_x = 3; 
    static const int default_y = 3; 
protected: 
    T** cells; 
    int x_size; 
    int y_size; 
}; 

回答

4
Matrix<T> Matrix(const Matrix<T>& src); 

错误告诉你什么是错的。构造函数可能没有返回类型,只是删除Matrix<T>返回类型。

编辑:关于你为什么不能使用返回类型就可以了,例如,寻找here

+0

感谢。有效 – FleshGod

相关问题