Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Static Variable

3 views
Skip to first unread message

t...@gmx.at

unread,
Sep 6, 2008, 7:49:45 AM9/6/08
to
Hello,

I am linking the following .cpp file to my program (approx. 800
modules), but the constructor is never called:

Foo.cpp:
#include <iostream>
static class Foo
{
public:
Foo() { std::cout << "Foo Constructor is called" << std::endl;}
} foo1;

If I am adding this code snippet to some other .cpp file with more
code and dependencies to other modules, the constructor is called. But
I don't understand why the constructor sometimes is called and
sometimes not. I am using g++ 3.4.6.
Is this a bug? Is there a work around?

Thanks

0 new messages