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]

Re: Code compiles with g++ 3.3 but not g++ 4.4


Hi David,

On Fri, Oct 16, 2009 at 10:58:33AM -0700, daviddoria wrote:
> 
> With this code:
> http://www.rpi.edu/~doriad/Daniweb/maxflow/
> If I run
> 
> g++ Example.cpp graph.cpp
> 
> with g++ 3.3, everything works fine. However if I run the same command with
> g++ 4.4, I get this error:
> 
> Example.cpp:(.text+0x38): undefined reference to `Graph<int, int,
> int>::Graph(int, int, void (*)(char*))'
as far as I understand the C++ - standard, the statement "template class
Graph<int,int,int>;" does define the class "Graph<int,int,int>" and
declare all member functions. However, it does NOT define the member
functions of Graph<init,int,int>.
> Does anyone know how I can get this to work with g++ 4.4?
If you explicitely instantiate the template member function, it will
work:

template class Graph<int,int,int>::Graph(int, int, void (*)(char *));


(Besides: your code does not compile - "NULL" is not defined, you should
a e.g. #include <cstdlib> :-)

HTH,

Axel


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