In C++, I want to define an object as a member of a class like this:
Object myObject;
However doing this will try to call it\'s parameterle
If you have access to boost, there is a handy object that is provided called boost::optional<> - this avoids the need for dynamic allocation, e.g.
class foo
{
foo() // default std::string ctor is not called..
{
bar = boost::in_place("foo"); // using in place construction (avoid temporary)
}
private:
boost::optional bar;
};