没有合适的资源?快使用搜索试试~ 我知道了~
首页typedef struct 与 struct 的区别及初始化
typedef struct 与 struct 的区别及初始化 typedef struct 与 struct 的区别及初始化 typedef struct 与 struct 的区别及初始化 typedef struct 与 struct 的区别及初始化 typedef struct 与 struct 的区别及初始化
资源详情
资源评论
资源推荐

初始化例子
typedef struct PhotoInfo
{
CString csName;
CString csStoragePath;
CString csLocalPath;
CString csStorageBakPath; // the storage path of proccessed photo
CString csLocalBakPath; // the local path of proccessed photo
// 2009/03/12 Keiichi Yoshihara modified -start-
CString csCameraName;
bool bNewCreate;
// 2009/03/12 Keiichi Yoshihara modified -end-
HANDLE hImage;
HANDLE hImageProcessed;
LPBYTE pDataProcessed;
bool bRead;
bool bNeedUpdate;
bool bShown;
bool bConfirmed;
//ASDC for 補正済みコマ表示明確化 AS
bool bProcessed;
//ASDC for 補正済みコマ表示明確化 AE
ColorCorrection::CFColorData colorData;
vector<CString> vecSetupList;
ROTATEANGLE_e nRotate;
PhotoInfo()
{
csName = NULL_STRING;
csStoragePath = NULL_STRING;
csLocalPath = NULL_STRING;
csStorageBakPath = NULL_STRING;
csLocalBakPath = NULL_STRING;
// 2009/03/12 Keiichi Yoshihara modified -start-
csCameraName = NULL_STRING;
bNewCreate = false;
// 2009/03/12 Keiichi Yoshihara modified -end-
hImage = NULL;
hImageProcessed = NULL;
pDataProcessed = NULL;
bRead = false;
bNeedUpdate = false;
bShown = false;
bConfirmed = false;
vecSetupList.clear();
nRotate = e_Origin;
//ASDC for 補正済みコマ表示明確化 AS
bProcessed = false;
//ASDC for 補正済みコマ表示明確化 AE
colorData.m_nCyan = 0;
colorData.m_nMagenta = 0;
colorData.m_nYellow = 0;
colorData.m_nDensity = 0;
colorData.m_bSetup = 0;
colorData.m_nIndividualSetup = 0;
}
}PHOTOINFO_t;
typedef struct OrderInfo
{
CString csOrderId;

CString csLastAccessTime;
CString csOrderPath;
CString csOutOrderPath;
CString csErrOrderPath;
CString csStoragePath;
CString csLocalOrderPath;
CString csStorageColorPath;
CString csLocalColorPath;
bool bRead;
bool bFinished;
bool bFirstRead;
bool bConfirmed;
bool bErrorOrder;
//<--- 2009/03/31 FFS K.Yoshihara added
bool bNewCreate;
//2009/03/31 FFS K.Yoshihara added --->
vector <PHOTOINFO_t> photoVec;
OrderInfo()
{
csOrderId = NULL_STRING;
csLastAccessTime = NULL_STRING;
csOrderPath = NULL_STRING;
csOutOrderPath = NULL_STRING;
csErrOrderPath = NULL_STRING;
csStoragePath = NULL_STRING;
csLocalOrderPath = NULL_STRING;
csStorageColorPath = NULL_STRING;
csLocalColorPath = NULL_STRING;
bRead = false;
bFinished = false;
bFirstRead = true;
bConfirmed = false;
bErrorOrder = false;
bNewCreate = false;
}
}ORDERINFO_t;
1. 由于对 typedef 理解不够,因此从网上摘录了一些资料,整理如下:
2.
3. C/C++中 typedef struct 和 struct 的用法
4.
5. struct _x1 { ...}x1; 和 typedef struct _x2{ ...} x2; 有什么不同?
6.
7.
8. 其实, 前者是定义了类_x1 和_x1 的对象实例 x1, 后者是定义了类_x2 和_x2 的类别名 x2 ,
9.
10. 所以它们在使用过程中是有取别的.请看实例 1.
11.
12. [知识点]
13.
14. 结构也是一种数据类型, 可以使用结构变量, 因此, 象其它 类型的变量一样, 在使用结构变量时
要先对其定义。
15.
16. 定义结构变量的一般格式为:
17.
18. struct 结构名
19.
20. {
21.
22. 类型 变量名;
23.

24. 类型 变量名;
25.
26. ...
27.
28. } 结构变量;
29.
30. 结构名是结构的标识符不是变量名。
31.
32.
33.
34. 另一种常用格式为:
35.
36.
37.
38. typedef struct 结构名
39.
40. {
41.
42. 类型 变量名;
43.
44. 类型 变量名;
45.
46. ...
47.
48. } 结构别名;
49.
50.
51.
52.
53.
54. 另外注意: 在 C 中,struct 不能包含函数。在 C++中,对 struct 进行了扩展,可以包含函数。
55.
56.
57.
58. ======================================================================
59.
60.
61.
62. 实例 1: struct.cpp
63.
64.
65.
66. #include <iostream>
67.
68. using namespace std;
69.
70. typedef struct _point{
71.
72. int x;
73.
74. int y;
75.
76. }point; // 定义类,给类一个别名
77.
78.
79.
80. struct _hello{
81.
82. int x,y;
83.
84. } hello; // 同时定义类和对象
85.
86.
87.
剩余10页未读,继续阅读

















安全验证
文档复制为VIP权益,开通VIP直接复制

评论3