C++中的前向引用或声明

CVe*_*tex 4 c++ syntax forward-declaration

如何在C++中转发引用/声明以避免循环头文件引用?

我在头文件中有#ifndef防护,但是内存告诉我我需要这个前向引用的东西 - 我之前使用过的<>但是不记得怎么做.

ant*_*tik 15

你预先声明了这个课程而不包括它.例如:

//#include "Foo.h" // including Foo.h causes circular reference
class Foo;

class Bar
{
...
};
Run Code Online (Sandbox Code Playgroud)