Hello everyone,
Confused why the following code can compile when we use :: to invoke non-static function. Especially, in the sample below, is it possible to call non-static member if T is not int? Why compiler allows the following code to compile?
Code:#include <iostream> using namespace std; template <class T> struct FooTrait { public: int foo1(); }; template<> struct FooTrait<int> { static int foo1() {cout << "Hello Foo1" << endl; return 0;} }; template <class T1, class T2 = FooTrait<T1>> struct Foo { public: int foo() { T2::foo1(); // possible to call non-static member if T is not int? return 0; } }; int main() { Foo<int> f; f.foo(); return 0; }
thanks in advance,
George