Mail Archives: djgpp/1997/05/11/03:11:58
Hi!
Im a C user of Djgpp that has to switch to C++ for some projects .
Can any1 help me using templates with djgpp 2.7.2 og g++ 2.7.2.1 under
FreeBSD ?
This is my problem : this simple class doesn't compile !
WHY!??? ... :-<<<<
(file "myclass.cc")
#include "myclass.h"
template <class T> myclass<T>::myclass(T tinf)
{
cout << "Hello World!" << endl;
inf = tinf;
}
(file "mytest.cc")
#include "myclass.h"
int main(void)
{
myclass<int> myc(3);
return 0;
}
(file "myclass.h");
#include <iostream.h>
template <class T>
class myclass
{
public:
myclass(T);
private:
T inf;
};
class myclass<int>; // without this the linker says "undefined reference"!!!
...and this is the compile result (same under djgpp/g++):
[matra] $ g++ myclass.cc mytest.cc -o mytest
mytest.cc: In function `int main()':
mytest.cc:5: variable `class myclass<int> myc' has initializer but incomplete type
mytest.cc:5: aggregate `class myclass<int> myc' has incomplete type and cannot be initialized
Can any1 help me posting a WORKING example of templates under djgpp?
hoping for help...
cul8r
- Raw text -