Suppose I define a class Foo
that does not implement the default constructor. In addition, I have a class Bar
that owns an instance Foo
:
class Foo() {
private:
int m_member;
public:
Foo( int value ) : m_member(value) { }
};
class Bar() {
private:
Foo m_foo;
public:
Bar( ) {
int something;
}
};
The code, as shown, will not work because it is Bar
trying to call the default constructor Foo
.
Now I'm trying to make the constructor Bar
first define something
, and then pass the result to the constructor Foo
.
- Bar
/ Foo
m_something
. , , m_foo
-.
Foo
, , Foo
( ).
? /?