I only have the hpp file for the school assignment in C ++ (I am not allowed to add the cpp file, the declaration and implementation must be written to the file).
I wrote this code inside it:
template<class T> class Matrix { void foo() {
I would like to add another foo method, but this foo() will be specialized only for <int> . I read in some places that I need to declare a new specialization class for this. But I want the specialized foo lie only under the original foo , so it will look like this:
template<class T> class Matrix { void foo(T x) {
- Why am I getting an error for this syntax ("expected unqualified identifier before" and "token")?
- Why is this impossible?
- How can I fix this without declaring a new specialized class?
thanks
source share