0

I created an enum class called Colour

enum Colour{
    RED, YELLOW, GREEN, BLUE, WHITE
}; 

Now I am creating a template class called Row. This 'row' class should be templated for a certain colour.

This is what I have written so far in my code:

#include <iostream>
#include "Colour.h"

template <Colour T> class QwintoRow; 
template <Colour T> ostream& operator<<(ostream&, const QwintoRow<T> &qr);

template <Colour T> 
class QwintoRow{

// stuff
};

I guess my question is, does this code make sense? I'm a bit confused with when you would write

template <Typename T>
template <Class T>

and does it make sense to write template ?

Thanks

cooldecola
  • 118
  • 7
  • You meant to enter enum *class* Colour? – franji1 Apr 15 '21 at 19:14
  • 1
    On the last part of the question, [Difference of keywords 'typename' and 'class' in templates?](https://stackoverflow.com/questions/2023977) – user4581301 Apr 15 '21 at 19:14
  • 4
    You may be confused between traditional templates where you pass a *type*, and [non-type template parameters](https://en.cppreference.com/w/cpp/language/template_parameters#Non-type_template_parameter) where you pass a *value*. `template ` is conceptually the same as `template `. – 0x5453 Apr 15 '21 at 19:15
  • 2
    `template ` and `template ` mean the same thing, namely that `T` is a *type template parameter*. OTOH `template ` and `template ` and `template ` mean a different thing, namely, that `T` is a *non-type template parameter*. Both type and non-type parameters make sense and are usable in their own ways. – n. m. could be an AI Apr 15 '21 at 19:17

0 Answers0