#include <iostream>
// source1.h
class A {
public:
class B;
public:
explicit A(B &);
void use_b();
private:
B & b;
};
// source2.h
class A::B {
public:
B();
void do_something();
};
// source3.cpp
A::A(B & pB) : b(pB) { }
void A::use_b()
{
b.do_something();
}
// source4.cpp
A::B::B() { }
void A::B::do_something()
{
std::cout << "Did something." << std::endl;
}
// main
int main()
{
A::B b;
A a(b);
a.use_b();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKLy8gc291cmNlMS5oCmNsYXNzIEEgewpwdWJsaWM6CiAgICBjbGFzcyBCOwoKcHVibGljOgogICAgZXhwbGljaXQgQShCICYpOwoKICAgIHZvaWQgdXNlX2IoKTsKCnByaXZhdGU6CiAgICBCICYgYjsKfTsKCi8vIHNvdXJjZTIuaApjbGFzcyBBOjpCIHsKcHVibGljOgogICAgQigpOwogICAgdm9pZCBkb19zb21ldGhpbmcoKTsKfTsKCi8vIHNvdXJjZTMuY3BwCgpBOjpBKEIgJiBwQikgOiBiKHBCKSB7IH0KCnZvaWQgQTo6dXNlX2IoKQp7CiAgICBiLmRvX3NvbWV0aGluZygpOwp9CgovLyBzb3VyY2U0LmNwcAoKQTo6Qjo6QigpIHsgfQoKdm9pZCBBOjpCOjpkb19zb21ldGhpbmcoKQp7CiAgICBzdGQ6OmNvdXQgPDwgIkRpZCBzb21ldGhpbmcuIiA8PCBzdGQ6OmVuZGw7Cn0KCi8vIG1haW4KCmludCBtYWluKCkKewogICAgQTo6QiBiOwogICAgQSBhKGIpOwoKICAgIGEudXNlX2IoKTsKfQo=