help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

template function in template class


From: mathieu
Subject: template function in template class
Date: Sat, 27 Oct 2007 15:06:38 -0700
User-agent: G2/1.0

Hi there,

  Why do I need the template keyword in this case:

template <typename T1>
struct A
{
  template <typename T2>
  void foo() {}
};

template <typename T1>
struct B
{
  template <typename T2>
  void bar() {
    A<T1> a;
    // a.foo<T2>(); // does not compile with gcc
    a.template foo<T2>();
  }
};

int main()
{
  B<int> b;
  return 0;
}

Thanks,
-Mathieu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]