Quick question on template specializations

Ok, if I have a template like this: template <class T, class Y> class myclass { ... };
And I have a template specialization like this: template <> class myclass <char> { ... };

How will the compiler know whether I'm referring to T or Y in the template specialization?
Have you tried compiling it and seeing if it gives you any errors?

I don't think it would work though...unless you assigned a default type to Y.
Last edited on
Hint: your code doesn't compile as is. The compiler error should be obvious to fix, and once you fix it, the answer to your question is obvious.
Well, I learnt something new today. I will probably forget it in six or so hours due to limited application, though. Just like I did with ... and ... .
"main.cpp:33: error: wrong number of template arguments (1, should be 2)"

Huh. So I have to explicitly define in the template specialization what every template parameter has to be. WHY didn't I think of that, it's blatantly obvious >_> . Thanks anyway :P
You are only partially specializing. So you still have to leave the second parameter templated (or the first, whichever you want).

Topic archived. No new replies allowed.