Reputation:
Why the following code doesn't compile?
namespace mtm {
template<class T>
class Matrix {
private:
public:
class AccessIllegalElement;
};
Matrix::AccessIllegalElement{};
}
I'm trying to implement the inner class for handling errors
Error I get:
'Matrix' is not a class, namespace, or enumeration
Plus, if inside AccessIllegalElement I want to write a function that prints the illegal index what is preferable?
1) to define a function that takes one parameter
2) to give every class object a member called index to save that data
Upvotes: 0
Views: 274
Reputation: 169058
Matrix
is a template, not a class. You need to let the compiler know the template arguments of this template when you declare/define inner items:
template <typename T>
class Matrix<T>::AccessIllegalElement {};
Upvotes: 1