c++ - How to forbidden using object to static member function -
i have simple class, , static member function:
class matrix { public: static matrix returnsomething ( matrix &m ) { return matrix(2,2); } };
main function:
int main() { matrix matrix(2,2); // matrix matrix m = matrix::returnsomething ( matrix ) // should use way m.print() // shows matrix // can use way // matrix m; m.returnsomething ( matrix ) // how make not allowed?? m.print() // here matrix null, wont show }
how it?
edit:
i have added print function shows problem
why not use helper class?
class matrixhelper { public: static matrix returnsomething ( matrix &m ) { return matrix(2,2); } };
then invocation be:
matrixhelper::returnsomething ( matrix )
Comments
Post a Comment