From: Arun Saini <arunsaini@yahoo.com>
To: gcc@gcc.gnu.org
Subject: Undefined reference to static member in templated class
Date: Wed, 18 Jul 2001 09:43:00 -0000 [thread overview]
Message-ID: <20010718164254.68869.qmail@web10506.mail.yahoo.com> (raw)
hi all,
I am using gcc-2.95.3 on AIX 4.3.3 / RS/6000. I am enclosing here a small
piece of code that compiled and executed correctly on gcc-3.0 on a Linux
system. It however fails on the AIX system.
#include<cstdio>
enum eTables
{
tbl1,
tbl2
};
template <class a, eTables e> class test
{
private:
static test<a, e> * foo;
protected:
public:
test();
virtual ~test();
static test<a, e> *Instance();
}; //class test
template <class a, eTables e>
test<a, e>
*test<a, e>::foo = NULL;
template <class a, eTables e>
test<a, e>::test()
{
}
template <class a, eTables e>
test<a, e>::~test()
{
}
template <class a, eTables e>
test<a,e>
*test<a, e>::Instance()
{
if (foo == NULL)
{
foo = new test<a, e>;
}
return(foo);
}
int main()
{
test<int, tbl1> *pobj;
pobj = test<int, tbl1>::Instance();
}
# g++ testFinal.cpp
/tmp/cc8zh32c.o(.pr+0x13e):testFinal.cpp: undefined reference to `test<int,0>::foo'
/tmp/cc8zh32c.o(.pr+0x14e):testFinal.cpp: undefined reference to `test<int,0>::foo'
/tmp/cc8zh32c.o(.pr+0x21a):testFinal.cpp: undefined reference to `test<int,0>::foo'
/tmp/cc8zh32c.o(.tc+0x0):testFinal.cpp: undefined reference to `test<int,0>::foo'
collect2: ld returned 1 exit status
Any ideas why this might be happening????
Arun Saini
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
next reply other threads:[~2001-07-18 9:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-18 9:43 Arun Saini [this message]
2001-07-18 12:25 ` David Edelsohn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010718164254.68869.qmail@web10506.mail.yahoo.com \
--to=arunsaini@yahoo.com \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).