我想在 C++ 中实现数据访问对象模式,但最好不要使用多重继承和/或提升(我的客户不喜欢)。
你有什么建议吗?
最佳答案
OTL (otl.sourceforge.net) 是一个优秀的 C++ 数据库库。它是一个单独的包含文件,因此没有与 Boost 相关的所有复杂性(正确或错误!)。
就 DAO 本身而言,您有很多选择。隐藏数据库实现最简单的方法就是使用 C++ 风格的接口(interface),并在特定的实现中实现数据访问层。
class MyDAO { // Pure virtual functions to access the data itself } class MyDAOImpl : public MyDAO { // Implementations to get the data from the database }
关于c++ - 数据访问对象模式实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/116646/