由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - One question about Void pointer (转载)
相关主题
问个编程,系统,网络有关的综合问题。请教下copy list with random pointer
问个结构体的大小问题发一些面世题,C Programming
c语言实现TreeFee一个GOOG的二叉树面试题
知道这里计算机的大牛多,问个题目~刚刚电面bloomberg,被问到一个没看到过的问题
array of pointers to functionsc模拟c++的继承和多态
什么情况下pass by reference比pass by pointer好?定义一个数组, 巨简单的一个问题
copy link with random additional pointers又问几个c语言编程的题目
一个简单的java题请教一个 c++ member function pointer 问题
相关话题的讨论汇总
话题: void话题: pointer话题: uint16话题: struct话题: next
进入JobHunting版参与讨论
1 (共1页)
s********k
发帖数: 6180
1
【 以下文字转载自 Programming 讨论区 】
发信人: silverhawk (silverhawk), 信区: Programming
标 题: One question about Void pointer
发信站: BBS 未名空间站 (Mon Mar 28 10:32:50 2011, 美东)
Is it risk to use void pointer in the following case:
typedef struct
{
void *next;
UINT16 xx;
UINT16 yy;
byte zz;
} a;
mostly, I think
struct a
{
struct a *next;
UINT16 xx;
UINT16 yy;
byte zz;
};
could be better, but is there any risk to use void pointer? what we should
pay attention in order to carefully manipulate the pointer in this case?
thanks
c********1
发帖数: 161
2
For me, I prefer the second one if your idea is to create a kind of linked
list whose "next" pointer points to the next element of the same data
structure. And this should be safe.
For the void pointer, it just means a pointer pointing to a void type. So
you may have to define how large you have to allocate memory for "next" to
point to and you may need to do some necessary type casting.
So, it really depends on your program.
1 (共1页)
进入JobHunting版参与讨论
相关主题
请教一个 c++ member function pointer 问题array of pointers to functions
G公司电面两轮什么情况下pass by reference比pass by pointer好?
C++ Q33: typedef (B4_20)copy link with random additional pointers
请教一个C++的小问题: Node *&curr Vs Node *curr一个简单的java题
问个编程,系统,网络有关的综合问题。请教下copy list with random pointer
问个结构体的大小问题发一些面世题,C Programming
c语言实现TreeFee一个GOOG的二叉树面试题
知道这里计算机的大牛多,问个题目~刚刚电面bloomberg,被问到一个没看到过的问题
相关话题的讨论汇总
话题: void话题: pointer话题: uint16话题: struct话题: next