第4章 类和对象二.pptVIP

  • 1
  • 0
  • 约3.02万字
  • 约 159页
  • 2017-09-07 发布于上海
  • 举报
第4章 类和对象二

第*页 共159页 4.10 本章小结 第*页 共159页 本章结束。。。 休息一会儿。。。 第*页 共159页 4.7 常类型 4.7.1 常引用 4.7.2 常对象 4.7.3 常对象成员 第*页 共159页 4.7.1 常引用 如果在说明引用时用const修饰,则被说明的引用为常引用。 常引用的说明形式如下: const 类型说明符 引用名; 第*页 共159页 4.7.1 常引用 例如: int a=5; const int b=a; 其中,b是一个常引用,它所引用的对象不允许更改。 第*页 共159页 例4.28 常引用作函数形参。 #includeiostream.h int add(const int i,const int j); void main( ) { int a=20; int b=30; couta+b=add(a,b)endl; } int add(const int i,const j) { return i+j; } 返回 第*页 共159页 4.7.2 常对象 如果在说明对象时用const修饰,则被说明的对象为常对象。 常对象的说明形式如下: 类名 const 对象名[(参数表)]; 或者 const 类名 对象名[(参数表)]; 第*页 共159页 4.7.2 常对

文档评论(0)

1亿VIP精品文档

相关文档