I have these two classes:
class Foo
{
public:
Foo() { std::cout << "in Foo constructor" << std::endl; }
};
class Bar
{
public:
Bar() {};
Bar(Foo foo);
private:
Foo m_foo;
};
Bar::Bar(Foo foo) :
m_foo(foo)
{
std::cout << "in Bar constructor with argument Foo" << std::endl;
}
int main() {
Bar bar(Foo()); // is something wrong here ?
return 0;
}
I compiled and excuted it , nothing printed on screen, what did Bar bar(Foo())
do ?
I have seen similarity in Do the parentheses after the type name make a difference with new? and Foo f = Foo(); // no matching function for call to 'Foo::Foo(Foo)', but I still can't figure out.