Originally Posted by
brewbuck
Do you really want your code to suddenly become wrong just because somebody declares a global variable named 'f'?
To me, going from "compiles" to "doesn't compile" based on whether I declare a variable doesn't make much sense.
I cant seem to get that to happen via MS VC which does compile with references to the parent class variables.
Maybe I did something wrong.
Code:
#include <iostream>
template<int i>
class A
{
public:
int f ;
void print()
{
std::cout << f << std::endl ;
}
} ;
template<int i>
class B : public A<i>
{
public:
B()
{
// f = i ;
}
} ;
int f = 2 ;
int main(int argc, char *argv[])
{
B<7> aa ;
aa.print() ;
}