Fluent interfaces and inheritance in C++

前端 未结 5 2051
失恋的感觉
失恋的感觉 2020-12-16 21:11

I\'d like to build a base (abstract) class (let\'s call it type::base) with some common funcionality and a fluent interface, the problem I\'m facing is the retu

5条回答
  •  难免孤独
    2020-12-16 21:28

    One solution would work like this:

    return *static_cast(&my_type().with_foo().with_bar());
    

    Using static_cast basically tells the compiler 'I know what I'm doing here'.

提交回复
热议问题