草庐IT

PlatformIndependantClass

全部标签

c++如何实现这种类结构?

我绞尽脑汁想找出如何编写跨平台类,同时避免虚拟函数的成本和平台特定版本类中的任何丑陋之处。这是我尝试过的。PlatformIndependantClass.hppclassPlatformIndependantClass{public:PlatformIndependantClass();std::stringGetPlatformName();private:PlatformIndependantClass*mImplementation;};Linux类.hpp#include"PlatformIndependantClass.hpp"classLinuxClass:publicP