如下一段代码求解释。。。。

极灿烂时光 2014-04-11 02:27:24
typedef struct tagCRDCARTESIAN{
double x;
double y;
double z;
}CRDCARTESIAN;
typedef CRDCARTESIAN *PCRDCARTESIAN;

这是在.h文件中的声明,不太清楚意思。
...全文
192 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
buyong 2014-04-14
  • 打赏
  • 举报
回复
Aaa(PCRDGEODETIC pcg, PCRDCARTESIAN pcc,double dSemiMajorAxis, double dFlattening); 你要知道这些是输入参数还是输出参数,查手册吧。 最简单的:
CRDGEODETIC cg;
CRDCARTESIAN cc;
Aaa(&cg, &cc, 0,0);
极灿烂时光 2014-04-11
  • 打赏
  • 举报
回复
引用 1 楼 zhao4zhong1 的回复:
声明了两个类型别名CRDCARTESIAN和PCRDCARTESIAN 分别对应“结构tagCRDCARTESIAN”和“指向结构tagCRDCARTESIAN的指针” typedef typedef type-declaration synonym; The typedef keyword defines a synonym for the specified type-declaration. The identifier in the type-declaration becomes another name for the type, instead of naming an instance of the type. You cannot use the typedef specifier inside a function definition. A typedef declaration introduces a name that, within its scope, becomes a synonym for the type given by the decl-specifiers portion of the declaration. In contrast to the class, struct, union, and enum declarations, typedef declarations do not introduce new types — they introduce new names for existing types. Example // Example of the typedef keyword typedef unsigned long ulong; ulong ul; // Equivalent to "unsigned long ul;" typedef struct mystructtag { int i; float f; char c; } mystruct; mystruct ms; // Equivalent to "struct mystructtag ms;" typedef int (*funcptr)(); // funcptr is synonym for "pointer // to function returning int" funcptr table[10]; // Equivalent to "int (*table[10])();"
谢谢!那么,在调用时应该怎么用呢?比如如何在Main函数中初始化一个结构体及其指针,然后调用函数。 函数定义为:Aaa(PCRDGEODETIC pcg, PCRDCARTESIAN pcc,double dSemiMajorAxis, double dFlattening);
小雨好赖床 2014-04-11
  • 打赏
  • 举报
回复
意思就是说 CRDCARTESIAN tagCrdcartesian; == struct tagCRDCARTESIAN tagCrdcartesian; PCRDCARTESIAN ptagCrdcartesian; == struct tagCRDCARTESIAN * ptagCrdcartesian; 这样定义两个变量 上面是结构体
赵4老师 2014-04-11
  • 打赏
  • 举报
回复
声明了两个类型别名CRDCARTESIAN和PCRDCARTESIAN 分别对应“结构tagCRDCARTESIAN”和“指向结构tagCRDCARTESIAN的指针” typedef typedef type-declaration synonym; The typedef keyword defines a synonym for the specified type-declaration. The identifier in the type-declaration becomes another name for the type, instead of naming an instance of the type. You cannot use the typedef specifier inside a function definition. A typedef declaration introduces a name that, within its scope, becomes a synonym for the type given by the decl-specifiers portion of the declaration. In contrast to the class, struct, union, and enum declarations, typedef declarations do not introduce new types — they introduce new names for existing types. Example // Example of the typedef keyword typedef unsigned long ulong; ulong ul; // Equivalent to "unsigned long ul;" typedef struct mystructtag { int i; float f; char c; } mystruct; mystruct ms; // Equivalent to "struct mystructtag ms;" typedef int (*funcptr)(); // funcptr is synonym for "pointer // to function returning int" funcptr table[10]; // Equivalent to "int (*table[10])();"

64,691

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧