我正在使用C ++ / cli,我有几个这样的问题..
Form1:有一个#include "UserControl1.h"
UserControl1:必须有#include "Formulario1.h"
原因:
UserControl1上节目的Form1。
Usercontrol1必须在Form1中运行一个方法,并且在不使用#include "Formulario1.h"
我试过这种方式访问Form1
(static_cast <FormDICOM ^> (this-> Parent)) -> ControleUC (1, false);
(static_cast <FormDICOM ^> (this-> Parent)) -> ControleUC (2, true);
但我在UserControl1中收到FormDICOM类型不存在的错误。
戴放置#include "FormDICOM.h"
但FormDICOM已经有#include "UserControl1.h"
并出现错误!
FormDICOM和UserControl1在同一名称空间中!
答案 0 :(得分:0)
Form1:有一个#include“UserControl1.h”
UserControl1:必须有#include“Formulario1.h”
在每个(和每个)头文件中放置多个“包含警示”。
在UserControl1.h头文件
中#ifndef USER_CONTROL1_H
#define USER_CONTROL1_H
#include "Formulario1.h"
..... <-- all the rest of the UserControl1.h header file contents
#endif // USER_CONTROL1_H
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
notice all caps and underscores like any #define should be, with
the USER_CONTROL1_H strongly related to the name of the header file
Do NOT use leading underscores in the defined name as that
can be mis-interpreted by the compiler
as the compiler prepends 1 or more underscores
on most all names it keeps in its' symbol table
在Formulario1.h头文件中
#ifndef FORMULARIO1_H
#define FORMULARIO1_H
#include "UserControl1.h"
---- <-- all the rest of the Formulario1.h header file contents
#endif // FORMULARIO1_H