由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 请问可以这样定义struct吗?
相关主题
One question about Void pointerint (*b)[2]; 是什么意思?
Questions about c codeC++ 菜鸟问一个关于template 的问题。
Question: Given a pointer to a function问一声大牛,c++不用pointer怎么编程?
请问const myClass &src 和myClass const &src有什么区别?为啥允许这样的const设计
pointer to function一道面试题
出个题考考大家:)one more interview question
C++里get array size的问题 (转载)c++ question
又问几个c语言编程的题目c ptr question
相关话题的讨论汇总
话题: struct话题: typedef话题: ptr话题: 定义话题: array
进入Programming版参与讨论
1 (共1页)
c***k
发帖数: 1589
1
想在struct a里定义一个dynamic array of pointers,每个pointer都指向另一个
struct b
typedef struct {
b **p
} a;
typedef struct {
int i;
} b;
那么我以后能不能用这个格式来访问
a *ptr;
ptr->p[3]->i;
l*****d
发帖数: 754
2
I think it is ok, except that the definition of b should appear before the d
efinition of a in this case.

【在 c***k 的大作中提到】
: 想在struct a里定义一个dynamic array of pointers,每个pointer都指向另一个
: struct b
: typedef struct {
: b **p
: } a;
: typedef struct {
: int i;
: } b;
: 那么我以后能不能用这个格式来访问
: a *ptr;

c***k
发帖数: 1589
3
But I got the compile time error :(
"dereferencing pointer to incomplete type"

d

【在 l*****d 的大作中提到】
: I think it is ok, except that the definition of b should appear before the d
: efinition of a in this case.

l*****d
发帖数: 754
4
Have you moved definition b in front of that of a?
Also have you allocated memory for array p[]?

【在 c***k 的大作中提到】
: But I got the compile time error :(
: "dereferencing pointer to incomplete type"
:
: d

c***k
发帖数: 1589
5
I forgot to cast, thank you ^^

【在 l*****d 的大作中提到】
: Have you moved definition b in front of that of a?
: Also have you allocated memory for array p[]?

1 (共1页)
进入Programming版参与讨论
相关主题
c ptr questionpointer to function
自学C语言-书和online resources (转载)出个题考考大家:)
Python Q: function pass in struct pointer, come back with data filledC++里get array size的问题 (转载)
问个c++ struct和指针问题又问几个c语言编程的题目
One question about Void pointerint (*b)[2]; 是什么意思?
Questions about c codeC++ 菜鸟问一个关于template 的问题。
Question: Given a pointer to a function问一声大牛,c++不用pointer怎么编程?
请问const myClass &src 和myClass const &src有什么区别?为啥允许这样的const设计
相关话题的讨论汇总
话题: struct话题: typedef话题: ptr话题: 定义话题: array