处理头文件相互包含的问题

时间:2019-06-14 00:18:28   收藏:0   阅读:110

问题

A.h 文件

#include <b.h>

A.cpp

使用 B中函数

B.h

#include <A.h>

B.cpp

使用A中函数

解决方案

A.h 文件

去掉#include <b.h>
class B; // 前置声明

A.cpp

新增#include <B.h>
使用 B中函数

B.h

去掉 #include <A.h>
class A; // 前置声明

B.cpp

新增#include <A.h>
使用A中函数

原文:https://www.cnblogs.com/eat-too-much/p/11020205.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!