首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > C/C++ > 17.5.8 Method body
【标  题】:17.5.8 Method body
【关键字】:17.5.8,Method,body
【来  源】:http://blog.csdn.net/masterall/archive/2006/05/08/712710.aspx

17.5.8 Method body

The method-body of a method declaration consists of either a block or a
semicolon.
Abstract and external method declarations do not provide a method
implementation, so their method bodies
simply consist of a semicolon. For any other method, the method body is a
block (§15.2) that contains the
statements to execute when that method is invoked.
When the return type of a method is void, return statements (§15.9.4) in
that method?s body are not permitted
to specify an expression. If execution of the method body of a void method
completes normally (that is, control
flows off the end of the method body), that method simply returns to its
caller.
When the return type of a method is not void, each return statement in that
method body must specify an
expression of a type that is implicitly convertible to the return type. The
endpoint of the method body of a valuereturning
method must not be reachable. In other words, in a value-returning method,
control is not permitted to
flow off the end of the method body.
[Example: In the example
class A
{
public int F() {} // Error, return value required
public int G() {
return 1;
}
public int H(bool b) {
if (b) {
return 1;
}
else {
return 0;
}
}
}
the value-returning F method results in a compile-time error because
control can flow off the end of the method
body. The G and H methods are correct because all possible execution paths
end in a return statement that
specifies a return value. end example]
17.6 Properties:【上一篇】
17.5.9 Method overloading:【下一篇】
【相关文章】
  • 模式设计(二)Factory Method(完整)
  • The Rule of Method Design
  • 设计模式笔记(12 STRATEGY & TEMPLATE METHOD)
  • 工厂方法模式 - Factory Method - 文物管理衙门 - 和申的为官经营之道第二部分
  • 模版方法模式 - Template Method Pattern - 穷人和富人的不同婚恋历程
  • 在Atlas服务器端实现中推荐使用Web Service而不是Page Method
  • Postfix: header/body checks using MySQL
  • Postfix: header/body_checks using MySQL
  • http: Request methods
  • 模版方法模式 Template Method Pattern — 穷人和富人的不同婚恋历程
  • 【随机文章】
  • 另类爆破——RamDisk9x/Me V1.5 算法分析
  • 眼见为实?
  • Linux管理——初学者指南
  • 保存图片流到数据库之后固定显示新法
  • IP、安全二合一
  • ASP分页类
  • 巧破IP地址下载限制<转>
  • 质数填表问题的回溯算法
  • ERP的价值不依赖于软件本身,而是企业对其的应用
  • winamp v2.X 歌词显示插件
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.