E
er
hi!
basically:
A::f<index>();//OK
A::g(index);//Fails//internally calls f<index>
C::f(index);//Fails.
why do i care? i'd like to make A::f private.
any help appreciated. thanks!
class A{
public:
A(unsigned int init_):init(init_){};
//unsigned int g(unsigned int index){return f<index>();};
//-error: 'index' cannot appear in a constant-
expression
//-error: no matching function for call to 'A::f()'
template<unsigned int i> unsigned int f(){
return init+i;
};
private:
unsigned int init;
};
class C{
public:
C(unsigned int init_):init(init_){};
template<unsigned int i> unsigned int f(unsigned int i){
return init+i;
};//error: no matching function for call to 'C::f(int)'
private:
unsigned int init;
};
basically:
A::f<index>();//OK
A::g(index);//Fails//internally calls f<index>
C::f(index);//Fails.
why do i care? i'd like to make A::f private.
any help appreciated. thanks!
class A{
public:
A(unsigned int init_):init(init_){};
//unsigned int g(unsigned int index){return f<index>();};
//-error: 'index' cannot appear in a constant-
expression
//-error: no matching function for call to 'A::f()'
template<unsigned int i> unsigned int f(){
return init+i;
};
private:
unsigned int init;
};
class C{
public:
C(unsigned int init_):init(init_){};
template<unsigned int i> unsigned int f(unsigned int i){
return init+i;
};//error: no matching function for call to 'C::f(int)'
private:
unsigned int init;
};