I am writing a template class of a matrix named Matrix, and I rewrite the default constructor like this:
template<typename _Tp, size_t m, size_t n> inline Matrix<_Tp, m, n>::Matrix() { for(size_t i = 0; i != m*n; ++i) val[i] = _Tp(0); } And in my test file I write this:
SC::Matrix<double, 3, 3> Mat(); All these are good when I build the program. But I always get wrong result when I run the test program.
And When I try to find reasons I find that the debugger always skip over definition of Mat; At the first I think that it may because I modified the files after I build this program, so I delete all the build results(automatically generated by cmake) and rebuild it. But it's useless, the problem is still there.
Is there anyone can help me find the reason? Did I provide enough information for this problem?
Matthat is supposed to be default initialized, or is it a declaration of a function which takes no argument and returns aSC::Matrix<double, 3, 3>object?():SC::Matrix<double, 3, 3> Mat;. Otherwise it may cause your compiler to think of it as a function declaration.