|
From: George B. <sib...@ya...> - 2011-09-16 18:35:53
|
On 9/16/2011 12:47 PM, Георгий Фамилия wrote:
>
> in MinGw, I get
>
> E:\Test>g++ -o a test.cpp
> test.cpp: In member function 'Type Sqr<Type>::getValue()':
> test.cpp:21:16: error: 'value' was not declared in this scope
>
> When I compile and run this code in Visual c++, I get
>
> obSqrInt.getValue() 400
>
> Explain me, please, why MinGW not compile this code.
I am not sure why protected inheritance does not work the same way in
templates as it works in normal classes.
As a quick solution, you can help the child template to find the
variable in the parent:
Type getValue() {
return Number<Type>::value * Number<Type>::value;
}
|