This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

What is the problem with this use of templates?


Hi,

I try to run this problem in g++ but it doesn't compiles. What is the problem?

//---START---

#include <iostream>

enum DIREC { goUp, goDown };

class MyClass {
public:
  template <DIREC dir>
  void
  doSomething() {
    std::cout << "i'm doing something\n";
  }
};

template<class T>
class MyVector {
public:
  MyVector() {}
  void execute();

};

template<class T>
void MyVector<T>::execute() {
  T* hello = new T();
  hello->doSomething<goDown>();
  delete hello;
}


int main() {
  MyVector<MyClass> mv;
  mv.execute();
}

//---END---

Here is my g++ version.
g++ (GCC) 3.3.5  (Gentoo Linux 3.3.5-r1, ssp-3.3.2-3, pie-8.7.7.1)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Thanks

--
Javier Andrés Mena Zapata
University of  Valle
Cali - Colombia


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]