avatar
c*e
1
according to BS, if a function has a return value non-void, it must return
sth in its definition.
however, the following code compile with Gcc/VC 7.1
int func (void) {}
why?
avatar
c*e
2
seems not the case for gcc 3.3

【在 c********e 的大作中提到】
: according to BS, if a function has a return value non-void, it must return
: sth in its definition.
: however, the following code compile with Gcc/VC 7.1
: int func (void) {}
: why?

avatar
g*g
3
Because C++ is a pain in the butt itself.
It's never a strong type language which an OOL should be.
avatar
r*y
4
If you use the return value, such like
cout << func();
compiler will report error.
If func() is a global function, VC compiler will report error too.
For member function, ok if return value not used.

【在 c********e 的大作中提到】
: according to BS, if a function has a return value non-void, it must return
: sth in its definition.
: however, the following code compile with Gcc/VC 7.1
: int func (void) {}
: why?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。