gpt4 book ai didi

c++ - VOID 是指 'nothing' 还是 'anything'

转载 作者:行者123 更新时间:2023-12-03 02:54:51 25 4
gpt4 key购买 nike

VOID 是什么意思?它的意思是“什么都没有”还是“什么都有”?

查字典,答案是什么都没有,但有些人说它意味着什么。我很困惑它是否与 null 意思相同还是有独特的含义。当我在谷歌上搜索它的含义时,我得到了空指针的结果以及许多我无法理解的东西,最后我是一名12年级的女孩。

最佳答案

在 C++ 中,void 在不同的上下文中可能表示不同的含义。例如,void指针表示可以指向任何对象的指针

int x = 0;
void *p = &x; // ok -- void pointers can point to any object.

但是当 void 作为函数的返回类型时,意味着该函数不返回任何内容。

void f()
{
cerr << "Hello there\n";
// No return, since the function has a void return type.
}

关于c++ - VOID 是指 'nothing' 还是 'anything',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11703046/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com