Mail Archives: djgpp/1999/12/30/08:00:28
From: | Adam Maj <Adam DOT Maj AT ifj DOT edu DOT pl>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | problem using "templates"
|
Date: | Thu, 30 Dec 1999 12:23:07 +0100
|
Organization: | Niewodniczanski Institute of Nuclear Physics, Krakow
|
Lines: | 42
|
Message-ID: | <386B409A.2432FDEE@ifj.edu.pl>
|
NNTP-Posting-Host: | maj.ifj.edu.pl
|
Mime-Version: | 1.0
|
X-Mailer: | Mozilla 4.7 [en] (Win98; I)
|
X-Accept-Language: | pl,en,da
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hi,
I have serious problem, connected with using " templates" in DJGPP. I
cannot use objects "static", because this leads to errors.
Here is small example of program "TEST. CC", that is causing errors:
#include <iostream.h>
template <class ccc> class my_class {
public :
static char* str;
};
template <class ccc> char* my_class<ccc>::str="abc";
main() {
cerr << my_class<int>::str << endl;
}
Here is announcement of error (from window "Message Window" in RHIDE) :
Compiling: test.cc
no errors
Creating: test.exe
Error: test.o: In function `main':
test.cc(1) Error: undefined reference to `my_class<int>::str'
There were some errors
If we will exchange declaration of variable type of variable " str"
from" char*" into" int" program will work (and compile oneself) well.
But I think that use of type" int" : is the only exception, when it is
possible to use static variable in "template". In remaining situations
program does not compile oneself, or works incorrect (when I use type"
long long int" program work, but returns unsuitable value of variable
"str").
How can I fix this bug ? Maybe there is (or will be) new version of GNU
(or DJGPP) ?
I am using version 202
If You can help, please answer.
Thanks a lot
Rafal Maj
- Raw text -