使用链式调用风格来增加C++代码的可阅读性
#include <iostream>
using namespace std;
class A {
public:
A(){}
void or_else() {
std::cout << "A::or_else" << std::endl;
}
};
class B {
public:
B(A a) : m_a(a) {}
A post() {
std::cout << "B::post" << std::endl;
return m_a;
}
private:
A m_a;
};
int main()
{
A a;
B b(a);
b.post().or_else();
}