在例如int compar中是const必需的(const void *,const void *) [英] is const necessary in eg int compar(const void *, const void *)
问题描述
qsort和
bsearch中的比较函数中是否需要关键字const?
int(* compar)(const void *,const void * )
如果指针无法解除引用,为什么担心指针对象
会被修改?
Is the keyword const necessary in the comparison function in qsort and
bsearch?
int (*compar)(const void *, const void *)
If the pointer cannot be dereferenced why worry if the pointed object
will be modified?
推荐答案
lo *************** @ gmail.c0m写道:
lo***************@gmail.c0m wrote:
是关键字const qsort和
bsearch中的比较函数需要什么?
int(* compar)(const void *,const void *)
如果指针无法解除引用,为什么担心指针对象
是否会被修改?
Is the keyword const necessary in the comparison function in qsort and
bsearch?
int (*compar)(const void *, const void *)
If the pointer cannot be dereferenced why worry if the pointed object
will be modified?
为什么指针不能被取消引用?
-
Ian Collins
Why can''t the pointer be dereferenced?
--
Ian Collins
" lovecreatesbea ... @ gmail.c0m" < lovecreatesbea ... @ gmail.comwrote:
"lovecreatesbea...@gmail.c0m" <lovecreatesbea...@gmail.comwrote:
比较函数中是否需要关键字const
qsort和bsearch中的
?
Is the keyword const necessary in the comparison function
in qsort and bsearch?
不是绝对必要,但谨慎。
Not strictly necessary, but prudent.
int(* compar)(const void *,const void *)
如果指针无法解除引用,为什么要担心
指向的对象是否会被修改?
int (*compar)(const void *, const void *)
If the pointer cannot be dereferenced why worry if the
pointed object will be modified?
当指针被转换为适当的对象
类型时,它们当然可以被解除引用,通常是。br />
-
Peter
When the pointer(s) are converted to the appropriate object
type, they certainly can be dereferenced, and usually are.
--
Peter
10月15日上午10:55,Peter Nilsson< ai ... @ acay.com.auwrote:
On Oct 15, 10:55 am, Peter Nilsson <ai...@acay.com.auwrote:
" lovecreatesbea ... @ gmail.c0m" < lovecreatesbea ... @ gmail.comwrote:
"lovecreatesbea...@gmail.c0m" <lovecreatesbea...@gmail.comwrote:
比较函数中是否需要关键字const
qsort和bsearch中的
?
Is the keyword const necessary in the comparison function
in qsort and bsearch?
不是绝对必要,但谨慎。
Not strictly necessary, but prudent.
int(* compar)(const void *,const void *)
int (*compar)(const void *, const void *)
如果指针无法解除引用,为什么要担心
指向的对象是否会被修改?
If the pointer cannot be dereferenced why worry if the
pointed object will be modified?
当指针转换为适当的对象
类型时,它们当然可以被解除引用,通常是.br />
When the pointer(s) are converted to the appropriate object
type, they certainly can be dereferenced, and usually are.
谢谢。
我忽略了这一点,原始指针上的const限定符将
仍然要求在相应的
对象上应用相同的qulifier。
Thank you.
I ignored this, the const qualifier on the original pointers will
still require the same qulifier to be applied on those appropriate
object.
这篇关于在例如int compar中是const必需的(const void *,const void *)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!