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

问题

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中函数

猜你喜欢

转载自www.cnblogs.com/eat-too-much/p/11020205.html
今日推荐