I have a class like this:
class Foo {
public:
Foo();
private:
SomethingProxy proxy;
MyBar myBar;
};
In the constructor body (not initializer list), I want to do this:
Foo::Foo() {
myBar.initializeProxy(proxy);
}
The code currently "works" for me, but is that guaranteed? Does the code invoke UB, or have any other problems?
These may not be relevant to the question, but here are some more details:
SomethingProxy
's default constructor initializes it properly to the required state.- Having
SomethingProxy
andMyBar
as members ofFoo
(as against pointers) is a business requirement, soinitializeProxy()
beingvirtual
(or not) is not relevant here.