public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Boris" <boris@gtemail.net>
To: help-gcc@gnu.org
Subject: problem with template and global/static variable
Date: Sun, 12 Dec 1999 17:11:00 -0000	[thread overview]
Message-ID: <831gvd$sov$1@news.rrz.Uni-Koeln.DE> (raw)

I just come from comp.lang.c++ where they told me I should ask here as it
must be a gcc linker problem. I hope you can help me.

I created a template that I can only use as a member of an object. If I try
to use a static or global variable of the template type I get a linking
error (gcc 2.7):

Clients.cpp:26: undefined reference to `Collector<int>::Collector(void)'

I have no idea why. It looks like that a constructor Collector(void) is
needed? The Collector template has a public constructor Collector(). Can't
this be used for global/static variables? Do I have to code another public
constructor for Collector: a Collector(void)?

Boris


WARNING: multiple messages have this Message-ID
From: "Boris" <boris@gtemail.net>
To: help-gcc@gnu.org
Subject: problem with template and global/static variable
Date: Fri, 31 Dec 1999 22:24:00 -0000	[thread overview]
Message-ID: <831gvd$sov$1@news.rrz.Uni-Koeln.DE> (raw)
Message-ID: <19991231222400.pdfQfE43oOrYiPoX4CaFZM773lEQHVbwpsH0CJ7z-eU@z> (raw)

I just come from comp.lang.c++ where they told me I should ask here as it
must be a gcc linker problem. I hope you can help me.

I created a template that I can only use as a member of an object. If I try
to use a static or global variable of the template type I get a linking
error (gcc 2.7):

Clients.cpp:26: undefined reference to `Collector<int>::Collector(void)'

I have no idea why. It looks like that a constructor Collector(void) is
needed? The Collector template has a public constructor Collector(). Can't
this be used for global/static variables? Do I have to code another public
constructor for Collector: a Collector(void)?

Boris


             reply	other threads:[~1999-12-12 17:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-12 17:11 Boris [this message]
1999-12-31 22:24 ` Boris

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='831gvd$sov$1@news.rrz.Uni-Koeln.DE' \
    --to=boris@gtemail.net \
    --cc=help-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).