I have a very simple matrix class with the following constructor:
template <typename Type>
SimpleMatrix<Type>::SimpleMatrix(const int &rows, const int &cols, const Type &val) {
for (int i = 0; i < rows; i++) {
vector<Type> col_vec(cols, val);
mat.push_back(col_vec);
}
}
Simple as it is, if I try to call it from main.cpp by doing the following:
SimpleMatrix<double> matrix(1,1,0.5);
The compiler throws the well-known error:
Undefined symbols for architecture x86_64:
"Matrix::SimpleMatrix<double>::SimpleMatrix(int const&, int const&, double const&)", referenced from:
_main in main.o
"Matrix::SimpleMatrix<double>::~SimpleMatrix()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Isn't that the way of using overloaded constructors in this case? I am starting to think this is a red herring and my XCode is playing up!