Operator Overloading - University of Georgia.ppt


文档分类:IT计算机 | 页数:约136页 举报非法文档有奖
1/136
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/136
文档列表 文档介绍
Chapter 10 Operator Overloading; Class string
C++ How to Program, 9/e
©1992-2014 by Pearson Education, Inc. All Rights Reserved.
©1992-2014 by Pearson Education, Inc. All Rights Reserved.
  Introduction
This chapter shows how to enable C++’s operators to work with objects—a process called operator overloading.
One example of an overloaded operator built into C++ is <<, which is used both as the stream insertion operator and as the bitwise left-shift operator..
C++ overloads the addition operator (+) and the subtraction operator (-) to perform differently, depending on their context in integer, floating-point and pointer arithmetic with data of fundamental types.
You can overload most operators to be used with class objects—piler generates the appropriate code based on the types of the operands.
©1992-2014 by Pearson Education, Inc. All Rights Reserved.
   Using the Overloaded Operators of Standard Library Class string
Figure demonstrates many of class string’s overloaded operators and several other useful member functions, including empty, substr and at.
Function empty determines whether a string is empty, function substr returns a string that represents a portion of an existing string and function at returns the character at a specific index in a string (after checking that the index is in range).
Chapter 21 presents class string in detail.
©1992-2014 by Pearson Education, Inc. All Rights Reserved.

Operator Overloading - University of Georgia 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数136
  • 收藏数0 收藏
  • 顶次数0
  • 上传人brnpnu31
  • 文件大小8.25 MB
  • 时间2018-06-05