ALT Linux Community general discussions
 help / color / mirror / Atom feed
* [Comm] вопрос по gcc (static)
@ 2004-12-16  5:14 Gleb Kulikov
  2004-12-16  6:33 ` Michael Holzman
  0 siblings, 1 reply; 2+ messages in thread
From: Gleb Kulikov @ 2004-12-16  5:14 UTC (permalink / raw)
  To: community

Джентельмены,

вопрос не в тему, но поможите, кто знает :)

gcc из поставки (3.2+). Не могу создать статический член класса (при линковке 
-- undefined reference)

Хорошо воспроизводится даже на совершенно дурацком тесте:

test.h:

class A
{
	public:
		static int i;

	A();
	~A();

	void inc();
};

test.cpp:

void A:: inc()
{
	++A::i;
};

Кто виноват и что делать?!

-- 
						Салют, /GLeb

UIN: 15341920
jabber://gleb@asd.iao.ru
netmail: 2:5005/78


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Comm] вопрос по gcc (static)
  2004-12-16  5:14 [Comm] вопрос по gcc (static) Gleb Kulikov
@ 2004-12-16  6:33 ` Michael Holzman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Holzman @ 2004-12-16  6:33 UTC (permalink / raw)
  To: community

On Thu, 16 Dec 2004 11:14:28 +0600, Gleb Kulikov <glebus@asd.iao.ru> wrote:
> вопрос не в тему, но поможите, кто знает :)

В таком виде должно работать:

class A
{
       public:
               static int i;

       A() {}
       ~A() {}

       void inc();
};

int A::i = 0;

void A::inc()
{
       ++A::i;
};

int main(int argc, char** arv[])
{
    A a;
}

Проверял на HP-UX, т.к. на работе временно доступа к Linux не имею.

-- 
Regards,
    Michael Holzman


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-16  6:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-16  5:14 [Comm] вопрос по gcc (static) Gleb Kulikov
2004-12-16  6:33 ` Michael Holzman

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git