The relevant part of my code is as follows:
In foo.h:
namespace foo_ns {
class Foo
{
static Class1 object1;
};
}
In foo.cpp
#include <foo.h>
namespace foo_ns {
Class1 Foo::object1(/*another object. Need to call copy constructor*/)
}
Here, "another object" is defined in main()
. Furthermore, Class1 is part of a large library and has no zero argument constructors, so simply removing the parenthesis gives a no matching function call
error during compilation. From what I understand, static initialization MUST be performed outside of any function.
So ithere any workaround for this?