c********e 发帖数: 383 | 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? | c********e 发帖数: 383 | 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?
| g*****g 发帖数: 34805 | 3 Because C++ is a pain in the butt itself.
It's never a strong type language which an OOL should be. | r****y 发帖数: 26819 | 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?
|
|