Vitus
Resource contributor
- Messages
- 1,480
- Country

I'm having a really dumb moment here. Let's say I have a class "Bar" defined with a constructor as follows:
An instance of this class is member of another class called "Foo":
Is there a way to call the custom constructor Bar(double value) without using new? Preferably, I'd like to have the value initialized in the header file of Foo:
But this doesn't seem to be working....
C++:
class Bar{
private:
double _value;
public:
Bar(double value);
}
C++:
class Foo{
private:
Bar bar;
}
Is there a way to call the custom constructor Bar(double value) without using new? Preferably, I'd like to have the value initialized in the header file of Foo:
C++:
class Foo{
private:
Bar bar(42.0);
}
But this doesn't seem to be working....



