I'm trying to get my head around mixing templates. I'm using it
as kind of a replacement for class inheritance as it seems to fit
better composition over inheritance. So I do something like:
mixin template NumberTemplate()
{
private:
int number = 0;
public:
int getNumber(int number)
{
return number;
}
}
interface INumber
{
getNumber(int number);
}
class Number : INumber
{
template NumberTemplate;
};
So two questions:
a) Is this correct usage?
b) It compiles if I just do:
template NumberTemplate()
{
private:
int number = 0;
public:
int getNumber(int number)
{
return number;
}
}
what is the difference between template and mixin template?