cuda编程指南_计算机编程中的“无效”指南

cuda编程指南

In computer programming, when void is used as a function return type, it indicates that the function does not return a value. When void appears in a pointer declaration, it specifies that the pointer is universal. When used in a function's parameter list, void indicates that the function takes no parameters. 

在计算机编程中 ,将void用作函数返回类型时,表示该函数未返回值。 当指针声明中出现void时,它指定指针是通用的。 在函数的参数列表中使用时,void表示函数不接受任何参数。

空函数返回类型 ( Void as a Function Return Type )

Void functions, also called nonvalue-returning functions, are used just like value-returning functions except void return types do not return a value when the function is executed. The void function accomplishes its task and then returns control to the caller. The void function call is a stand-alone statement. 

无效函数也称为非值返回函数,其用法与值返回函数一样,只不过void返回类型在执行该函数时不会返回值。 void函数完成其任务,然后将控制权返回给调用者。 void函数调用是一个独立的语句。

For example, a function that prints a message doesn't return a value. The code in C++ takes the form:

例如, 函数 ,它打印消息并没有返回值。 C ++中的代码采用以下形式:


void printmes


<


 cout << "I'm a function that prints a messag


<


int


<


 printmess


<

A void function uses a heading that names the function followed by a pair of parentheses. The name is preceded by the word "void," which is the type.

无效函数使用的标题为函数的名称,后跟一对括号。 名称前面带有单词“ void”(即类型)。

虚空作为函数参数 ( Void as a Function Parameter )

The void can also appear in the parameter list part of the code to indicate the function takes no actual parameters. C++ can take the empty parentheses, but C requires the word "void" in this usage. In C, the code takes the form:

空格也可以出现在代码的参数列表部分,以指示该函数不使用实际参数。 C ++可以带空括号,但是C在这种用法中需要单词“ void”。 在C中,代码采用以下形式:


void printmessage


<


 cout << "I'm a function that prints a messag

Note that the parentheses that follow the function name are not optional in any case.

请注意,函数名称后的括号在任何情况下都不是可选的。

虚空指针声明 ( Void as a Pointer Declaration )

The third use of void is a pointer declaration that equates to a pointer to something left unspecified, which is useful to programmers who write functions that store or pass pointers without using them. Eventually, it must be cast to another pointer before it is dereferenced. A void pointer points to objects of any data type.

void的第三种用法是一个指针声明,它等同于指向未指定对象的指针,这对于编写编写存储或传递指针而不使用它们的函数的程序员来说非常有用。 最终,在取消引用之前,必须将其强制转换为另一个指针。 空指针指向任何数据类型的对象。

翻译自: https://www.thoughtco.com/definition-of-void-958182

cuda编程指南

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值