可能的重复:
避免头文件的循环依赖
任务.h:
#ifndef Tasks_h
#define Tasks_h
#include "Executors.h"
class Task
{
Executor *current_executor;
};
#endif Tasks_h
执行者.h:
#ifndef Executors_h
#define Executors_h
#include "Tasks.h"
class Executor
{
Task *current_task;
};
#endif Executors_h
主.cpp:
#include <conio.h>
#include <stdio.h>
#include "Tasks.h"
#include "Executors.h"
int main()
{
Executor ex;
return 0;
}
编译错误:
Error 1 error C2146: syntax error : missing ';' before identifier 'current_task' c:\users\rain\documents\visual studio 2010\projects\text\text\executors.h 8
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\rain\documents\visual studio 2010\projects\text\text\executors.h 8
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\rain\documents\visual studio 2010\projects\text\text\executors.h 8
再次......在 C# 中我永远不会遇到这样的问题,但我尽我所能支持 C++ 并使用它。
不想在一个头文件中编写所有类