I was going through this link to learn about the typename keyword and doing some experiments
Following is the code ->
template<typename T>
void foo(T& t) {
T::i = 6;
}
class A {
public:
static int i;
int j;
};
int main() {
A a;
foo(a);
}
I am getting linker error mentioning
undefined reference to `A::i'
If I do t.j = 6; instead of T::i = 6;, program compiles and runs successfully.
Compiler - g++ 4.8.4 on linux ubuntu
Thanks