T
Thomas.Zauner
Hi again,
I have a quite old code to reactivate (still), and ran into the
following problem:
(This is a boild down ecample that doesn't do anything, i just want to
state the problem)
----------------------------------------------------------------------------------------------------------
template <class T , int N>
class Rec: public Rec<T,N-1>
{
public:
Rec(T i):Rec<T,N-1>(i){};
inline void access(T newt)
{
base_var=newt; // ERROR "not in scope"
//this->base_var=newt;
//Rec<T,1>::base_var=newt;
//Rec<T,N-1>::base_var=newt;
}
};
template <class T>
class Rec<T,1>
{
public:
Rec(T i){ base_var=i;};
protected:
T base_var;
};
int main(void)
{
Rec<int,3> int_vec(0);
int_vec.access(5);
return 0;
};
----------------------------------------------------------------------------------------------------------
Now my question.
Which of the three options would be "correct"
//this->base_var=newt;
//Rec<T,1>::base_var=newt;
//Rec<T,N-1>::base_var=newt;
and what is the difference? is there any?
Thank you in advance
Thomas
I have a quite old code to reactivate (still), and ran into the
following problem:
(This is a boild down ecample that doesn't do anything, i just want to
state the problem)
----------------------------------------------------------------------------------------------------------
template <class T , int N>
class Rec: public Rec<T,N-1>
{
public:
Rec(T i):Rec<T,N-1>(i){};
inline void access(T newt)
{
base_var=newt; // ERROR "not in scope"
//this->base_var=newt;
//Rec<T,1>::base_var=newt;
//Rec<T,N-1>::base_var=newt;
}
};
template <class T>
class Rec<T,1>
{
public:
Rec(T i){ base_var=i;};
protected:
T base_var;
};
int main(void)
{
Rec<int,3> int_vec(0);
int_vec.access(5);
return 0;
};
----------------------------------------------------------------------------------------------------------
Now my question.
Which of the three options would be "correct"
//this->base_var=newt;
//Rec<T,1>::base_var=newt;
//Rec<T,N-1>::base_var=newt;
and what is the difference? is there any?
Thank you in advance
Thomas