在MyData.h文件中定义了一个结构体:
typedef struct Height
{
int name;
int mHeight;
int mSize;
}Height,*HeightPtr;一开始,我在A类中定义了一个Height结构体变量,首在先A类的头文件中包函Height结构体所在的头文件
#include "MyData.h"
然后再声明Height结构体变量
HeightPtr uHeight1 uHeight2;以上结构体变量在A类中使用正常,没有任何问题。之后我又要在B类中使用这个结构体,于是在B类头文件中
#include "Mydata.h"
然后再声明Height结构体变量
HeightPtr uHeight1 uHeight2;这时候再编译程序,就报出错误:
error C2011: 'Height' : 'struct' type redefinition
如果我把B类头文件中的 #include "Mydata.h"注释掉,再编译,又会报出错误:
error C2146: syntax error : missing ';' before identifier 'uHeight1'
error C2501: 'HeightPtr' : missing storage-class or type specifiers
.
.
一堆错误。
typedef struct Height
{
int name;
int mHeight;
int mSize;
}Height,*HeightPtr;一开始,我在A类中定义了一个Height结构体变量,首在先A类的头文件中包函Height结构体所在的头文件
#include "MyData.h"
然后再声明Height结构体变量
HeightPtr uHeight1 uHeight2;以上结构体变量在A类中使用正常,没有任何问题。之后我又要在B类中使用这个结构体,于是在B类头文件中
#include "Mydata.h"
然后再声明Height结构体变量
HeightPtr uHeight1 uHeight2;这时候再编译程序,就报出错误:
error C2011: 'Height' : 'struct' type redefinition
如果我把B类头文件中的 #include "Mydata.h"注释掉,再编译,又会报出错误:
error C2146: syntax error : missing ';' before identifier 'uHeight1'
error C2501: 'HeightPtr' : missing storage-class or type specifiers
.
.
一堆错误。
解决方案 »
- SDI分割视图中的控件如何随着窗口改变和分割条拖动而自动调整大小
- 关于气泡程序的提问
- VC如何去除CHtmlCtrl的边框
- 请问在WIN32下,如何将List Control中的数据保存为TXT格式的文档?
- 1280*1024的对话框如何在 1366×768的笔记本上调试显示?
- 编译时的错误,请教?
- VC++7是否也提供了VC6的Source Browser工具,我想找到一个基类的drived class, 怎么找?
- 问一个关于列表的问题
- 如何给ribbon的按钮添加 图片消息提示?
- 谁能介绍一个IBM笔记本电脑的详细产品介绍网址???
- WS_EX_COMPOSITED会让窗口的控制按钮失去鼠标滑过效应
- 最高版本的C/C++ FOR WIN32是那个?
{
int name;
int mHeight;
int mSize;
}Height,*HeightPtr;名字一样
typedef struct tagHeight
{
int name;
int mHeight;
int mSize;
}Height,*HeightPtr;
可能是 typedef struct Height OtherName 该类型定义的原因,
我两次包涵数 MyData.h头文件,使得编译器在编译时,进行了两次
typedef struct Height
{
.
.
}Height,*HeightPtr;
定义,所以错这个错误,在MyData.h头文件中加上 #pragma once 就OK了。感谢!