无效指针 [英] void pointer
问题描述
什么是无效指针?
what is a void pointer?
推荐答案
" Niks" < NB ***** @ gmail.com>在消息中写道
news:11 ********************** @ g14g2000cwa.googlegr oups.com ...
"Niks" <nb*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
什么是void指针?
void * MyPointer;
void* MyPointer;
Niks写道:
什么是无效指针?
你的意思是指向无效的指针?
通用指针,普通地址。该类型从''malloc''
函数和''operator new''返回,并被''operator delete''
作为参数接受。通常,指向void的指针用于保存指向任何类型或未知类型的对象的指针。具有相同的对齐
要求和与''char *''相同的表示。除了
要求''void *''可以保存指向任何对象的指针,从指针到对象的指针转换为指向void的指针。
转换是隐含的,反之亦然可以使用''static_cast''。
V
You mean a pointer to void?
A generic pointer, a plain address. That type is returned from ''malloc''
function and from ''operator new'', and is accepted by ''operator delete''
as an argument. Usually a pointer to void is used to hold a pointer to
an object of any type or of an unknown type. Has the same alignment
requirements and the same representation as ''char*''. Along with the
requirement that ''void*'' can hold a pointer to any object comes the
standard conversion from a pointer to object to a pointer to void. That
conversion is implicit and the reverse can be done using ''static_cast''.
V
Victor Bazarov写道:
Victor Bazarov wrote:
Niks写道:
什么是无效指针?
一个通用指针,一个普通的地址。该类型从''malloc''
函数和''operator new''返回,并被''operator delete''
接受为参数。通常,指向void的指针用于保存指向任何类型或未知类型的对象的指针。具有相同的对齐要求和与''char *''相同的表示。随着''void *''的要求可以保存指向任何对象的指针,从指针到对象的标准转换到指向void的指针。那个
转换是隐含的,反过来可以使用''static_cast''来完成。
V
You mean a pointer to void?
A generic pointer, a plain address. That type is returned from ''malloc''
function and from ''operator new'', and is accepted by ''operator delete''
as an argument. Usually a pointer to void is used to hold a pointer to
an object of any type or of an unknown type. Has the same alignment
requirements and the same representation as ''char*''. Along with the
requirement that ''void*'' can hold a pointer to any object comes the
standard conversion from a pointer to object to a pointer to void. That
conversion is implicit and the reverse can be done using ''static_cast''.
V
它可以保持(是否足以容纳)指向成员函数的指针?
我知道指向成员函数的指针是具体的实现
,但我想知道标准是否说关于这一点。
谢谢,
Dan
Can it hold (is it big enough to hold) a pointer to a member function?
I know that the pointers to member functions are implementation
specific, but I was wondering if the standard says anything about this.
thanks,
Dan
这篇关于无效指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!