| delorie.com/archives/browse.cgi | search |
| Message-ID: | <007301c15846$1208b4c0$0101a8c0@hernan> |
| From: | "R. Grela" <rgrela AT ciudad DOT com DOT ar> |
| To: | <djgpp AT delorie DOT com> |
| Subject: | Compiling problem |
| Date: | Thu, 18 Oct 2001 23:30:50 -0300 |
| MIME-Version: | 1.0 |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Mailer: | Microsoft Outlook Express 5.00.2014.211 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2014.211 |
| Reply-To: | djgpp AT delorie DOT com |
I'm trying to compile a template class, I don't know what I am doing wrong:
I 've this: (it's the simplest test)
--- test.h ---
#ifndef _TEST_H
#define _TEST_H
template <class T>
class test
{
public:
test();
private:
T t;
};
#endif
--- end of test.h ---
--- test.cpp ---
#include "test.h"
template <class T>
test<T>::test()
{
}
--- end of test.cpp ---
--- main.cpp ---
#include "test.h"
void main()
{
test t;
}
--- end of main.cpp ---
--- makefile ---
main: test
gxx main.cpp test.o
test:
gxx -c test.cpp
--- end of makefile ---
---
gxx -c test.cpp
gxx main.cpp test.o
main.cpp: In function `int main(...)':
main.cpp:5: `test' undeclared (first use this function)
main.cpp:5: (Each undeclared identifier is reported only once
main.cpp:5: for each function it appears in.)
main.cpp:5: parse error before `;'
make.exe: *** [main] Error 1
---
If I don't use the template the program compiles and links ok. But with
template I receive that message.
Does anyone know how to compile ? is there a special switch for compiling ?
Thanks in advance!
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |