(1)
void放在函數前面,表示這個函數沒有傳回值。
如 void push(char dey)沒有特別指定返回值型態時,則是預設為int。
例如 push(char dey) 等效於 int push(char dey)。
When used as a function return type, the void keyword specifies that the function does not return a value.
(2)
void放在參數列,則表示這個函數沒有輸入的參數。
例如 char pop(void),它等效於 char pop()。
When used for a function's parameter list, void specifies that the function takes no parameters.
(3)
When used in the declaration of a pointer, void specifies that the pointer is "universal."
If a pointer's type is void *, the pointer can point to any variable that is not declared with the const or volatile keyword.
A void pointer cannot be dereferenced unless it is cast to another type.
A void pointer can be converted into any other type of data pointer.
A void pointer can point to a function, but not to a class member in C++.
沒有留言:
張貼留言