Each instantiation of a template class type is a different class.
Remember that the classes actually have a different name, and are not related by inheritance.
FixedNum<int,5>
is a unique name, and will be different from the class type FixedNum<int,6>
.
Therefor they can't access each other's protected members.
You will have to decalare all the "similar" templated classes as friends, like this:
template<typename T, int N> friend class FixedNum;
Besides that, using preprocessor #if over there won't work like you want it to.
The preprocessor, much like its name, process BEFORE the compiler starts to process all the code. So it only evaluates MACRO values and prprocessor definitions.