如何在另一个已经有这个#include 的对象上#include 一个对象? C++/客户端
how to #include an object on another object that already has this #include? c++/cli
我正在使用C++/cli,我有几个这样的问题..
Form1: 有一个 #include "UserControl1.h"
UserControl1: 必须有一个 #include "Formulario1.h"
原因:
在UserControl1上显示Form1。
有一次 Usercontrol1 必须 运行 Form1 中的一个方法,并且不使用 #include "Formulario1.h"
就无法访问 Form1 类型
我试过这种方式访问Form1
(static_cast <FormDICOM ^> (this-> Parent)) -> ControleUC (1, false);
(static_cast <FormDICOM ^> (this-> Parent)) -> ControleUC (2, true);
但我在 UserControl1 中收到错误消息,提示 FormDICOM 类型不存在。
Dai 放置 #include "FormDICOM.h"
但 FormDICOM 已经有 #include "UserControl1.h"
并出现错误!
FormDICOM 和 UserControl1 在同一个命名空间中!
Form1: has a #include "UserControl1.h"
UserControl1: must have a #include "Formulario1.h"
在每个(和每个)头文件中放置多个 'include guard'。
在 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
我正在使用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 类型不存在。
Dai 放置 #include "FormDICOM.h"
但 FormDICOM 已经有 #include "UserControl1.h"
并出现错误!
FormDICOM 和 UserControl1 在同一个命名空间中!
Form1: has a #include "UserControl1.h"
UserControl1: must have a #include "Formulario1.h"
在每个(和每个)头文件中放置多个 'include guard'。
在 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