I'm still learning the beauty of C++. I came across some code today and hopefully someone can give me some guidance. I have 2 classes
class B
{
public:
B( std::string s )
: m_string( s )
{
}
private:
std::string m_string;
};
class A
{
public:
A( B b )
: m_b( b )
{
}
private:
B m_b;
};
Main.cpp
A a = A(std::string("hello"));
I'm a bit confused about how can such initialization work? How does the compiler know that the std::string("hello) is to be passed to B's constructor instead?
I was trying to find relevant documentation but no luck..