你可以返回一个无效函数调用吗? [英] can you return a void function call?
问题描述
你好!
假设我有一个功能
void ShowMessage(string s);
(具有无效返回类型。)
在我的其他函数F中,还有一个void返回类型,我可以这样做吗?
void F(int i)
{
//我可以退货吗?
返回ShowMessage(Hi Dean); // ????
}
我似乎可以在Borland Builder6中做到这一点,但我没有
认为直到最近才有可能。这是一个特定于编译器的
设置吗?
THX!
Dean
Hi there!
Suppose I have a function
void ShowMessage(string s);
(that has a void return type.)
In my other function F, also with a void return type, can I do this?
void F(int i)
{
// Can I return this?
return ShowMessage("Hi Dean"); // ????
}
I can seem to be able to do this in Borland Builder6, but I didn''t
think it was possible until recently. Is this a compiler-specific
setting?
THX!
Dean
推荐答案
< de ********* @ yahoo.com>在消息中写道
news:11 ********************** @ l41g2000cwc.googlegr oups.com ...
<de*********@yahoo.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
你好!
假设我有一个函数
void ShowMessage(string s);
(它有一个void返回类型。)
在我的其他函数F中,还有一个void返回类型,我可以这样做吗?
void F(int i)
{
//我可以退货吗?
返回ShowMessage(嗨Dean); // ????
我似乎能够在Borland Builder6中做到这一点,但我并不认为这是可能的直到最近。这是一个特定于编译器的设置吗?
Hi there!
Suppose I have a function
void ShowMessage(string s);
(that has a void return type.)
In my other function F, also with a void return type, can I do this?
void F(int i)
{
// Can I return this?
return ShowMessage("Hi Dean"); // ????
}
I can seem to be able to do this in Borland Builder6, but I didn''t
think it was possible until recently. Is this a compiler-specific
setting?
不,这没有意义。从函数返回值无效
返回void。
-
Gary
No, this doesn''t make sense. It is invalid to return a value from a function
returning void.
--
Gary
即使值无效?
Even if the value is void?
我的意思是,似乎有道理说:
返回ShowMessage(" Hi"); //一行
然后写:
{
ShowMessage(" Hi"); //四行
返回;
}
I mean, it seems to make sense to say:
return ShowMessage("Hi"); // One line
then to write:
{
ShowMessage("Hi"); // Four lines
return;
}
这篇关于你可以返回一个无效函数调用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!