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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -