Menu

template

2002-11-30
2012-09-26
  • Nobody/Anonymous

    I have realized a template class Stack.
    In function main I have an instance:
      Stack<int> oneStack;

    If I implement the class in the file that contains main all is ok. If I split the program in:
      main.cpp // contains function main
      Stack.hpp // contains the interface of Stack
      Stack.cpp // contains the implemantation of Stack
    I obtain the following linker error:
      undefined reference to `Stack<int>::Stack(void)'
    I have found that I have to delay the translation of the template class. In Borland C++ I have to insert in Stack.cpp:
      #pragma option -Jgd
    and in main.cpp:
      #pragma option -Jgx
    What I have to do in Dev-c++ (rel. 4.9.6.0)?
    Thanks.
      by Francesco Pagano (fpagano@pep.it)

     
    • Anonymous

      Anonymous - 2002-12-05

      i assume you also added #include "Stack.hpp" to mai.cpp, when you move to multiple files. Asumming Stack.h is in the same directory as main.cpp, else include the relative path also.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.