问题描述
有一个头文件esUtil.h,定义了一个名为ESContext的结构,其中一个成员是userData。 userData是指向void的指针。
There's a header file, esUtil.h, with a definition for a structure called ESContext, and one of its members is userData. userData is a pointer to void.
程序的主体是这样的:
#include "esUtil.h"
typedef struct {
GLuint programObject;
} UserData;
int DoSomething(ESContext *esContext) {
UserData *userData = esContext->userData;
...
}
int main(int argc, char *argv[]) {
ESContext esContext;
UserData userData;
esStart(&esContext);
esContext.userData = &userData;
...
if(!DoSomething(&esContext))
return 0;
...
}
什么* userData在语句中:UserData * userData = esContext-> userData;
I'm confused by what "*userData" is in the statement: UserData *userData = esContext->userData;
如果它是一个指针,感谢您的解释。
And if it is a pointer, how it came into being without being declared. Thanks for any explanations.
推荐答案
是的,它是一个指针。
Yes, it is a pointer. The line
UserData *userData = esContext->userData;
声明一个变量 userData
code> UserData * (指向 UserData
的指针),并使用 esContext-&
。
declares a variable called userData
with type UserData *
(a pointer to UserData
) and initializes it with the value esContext->userData
.
这篇关于这是一个指针吗? (如果是,如何初始化?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!