我有一个简单的类和一个静态成员函数:
class Matrix
{
public:
static Matrix returnSomething ( Matrix &m )
{
return Matrix(2,2);
}
};
主功能:
int main()
{
Matrix matrix(2,2); // some matrix
Matrix m = Matrix::returnSomething ( matrix ) // I should use it that way
m.print() // it shows the matrix
// but I can use it too that way //
Matrix m;
m.returnSomething ( matrix ) // how to make this not allowed??
m.print() // but here the matrix is NULL, wont show anything
}
怎么做?
编辑:
我添加了一些显示问题的打印功能