这是什么意思无效在C,C ++和C#? [英] What does void mean in C, C++, and C#?

查看:82
本文介绍了这是什么意思无效在C,C ++和C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望得到的,其中术语VOID来自于基本面,为什么它会被称为无效。这个问题的用意是协助谁的人有没有C的经验和突然看着一个基于C codeBase的。

Looking to get the fundamentals on where the term VOID comes from and why it would be called void. The intention of the question is to assist someone who has no C experience and is suddenly looking at a C-based codebase.

推荐答案

基本上,它意味着无或无类型

Basically it means "nothing" or "no type"

有这一空白,用于3个基本方式:

There are 3 basic ways that void is used:


  1. 功能参数: INT myFunc的(无效)
    - 该功能将一无所获。

  1. Function argument: int myFunc(void) -- the function takes nothing.

函数返回值:无效myFunc的(INT)
- 该函数返回什么

Function return value: void myFunc(int) -- the function returns nothing

通用数据指针: void *的数据
- 数据是指向未知类型的数据,并且不能被解除引用

Generic data pointer: void* data -- 'data' is a pointer to data of unknown type, and cannot be dereferenced

注:无效函数中的参数是在C ++中可选的,因此 INT myFunc的()是完全同 INT myFunc的(无效),它是完全用C#冷落。它总是需要一个返回值。

Note: the void in a function argument is optional in C++, so int myFunc() is exactly the same as int myFunc(void), and it is left out completely in C#. It is always required for a return value.

这篇关于这是什么意思无效在C,C ++和C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆