The following code gives out an compilation error with a message "x is not declared in the scope", even though the child class can access the protected member, what is the reason for this?
template<class dt>
class test1
{
protected:
dt x;
};
template<class dt>
class test2:public test1<dt>
{
public:
void SetVals(int xarg)
{
x = xarg;
}
void GetVals()
{
cout<<x<<endl;
}
};
int main()
{
test2<int> obj;
obj.SetVals(10);
obj.GetVals();
return 0;
}