Having a simple class:
class A {
public:
A() {}
void set(int value) { value_ = value; }
private:
int value_;
};
and its global instance:
A a;
Is it OK to call method
set
on a not yet constructed objecta
? That can happen when for examplea.set(123)
is called from a constructor of another global object in another translation unit.Will the value in the object
a
set by callinga.set(123)
remain when the non-parametric and empty constructor ofA
is later called for objecta
?