- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter 9Technicalities Classes, etc..ppt
* Chapter 9Technicalities: Classes, etc. Bjarne Stroustrup /Programming Abstract This lecture presents language technicalities, mostly related to user defined types; that is, classes and enumerations. * Stroustrup/Programming/2015 Overview Classes Implementation and interface Constructors Member functions Enumerations Operator overloading * Stroustrup/Programming/2015 Classes The idea: A class directly represents a concept in a program If you can think of “it” as a separate entity, it is plausible that it could be a class or an object of a class Examples: vector, matrix, input stream, string, FFT, valve controller, robot arm, device driver, picture on screen, dialog box, graph, window, temperature reading, clock A class is a (user-defined) type that specifies how objects of its type can be created and used In C++ (as in most modern languages), a class is the key building block for large programs And very useful for small ones also The concept was originally introduced in Simula67 * Stroustrup/Programming/2015 Members and member access One way of looking at a class; class X { // this class’ name is X // data members (they store information) // function members (they do things, using the information) }; Example class X { public: int m; // data member int mf(int v) { int old = m; m=v; return old; } // function member }; X var; // var is a variable of type X var.m = 7; // access var’s data member m int x = var.mf(9); // call var’s member function mf() * Stroustrup/Programming/2015 Classes A class is a user-defined type class X { // this class’ name is X public: // public members -- that’s the interface to users // (accessible by all) // functions // types // data (often best kept private) private: // private members -- that’s the implementation details // (accessible by members of this class only) // functions // types // data }; * Stroustrup/Programming/2015 Struct and class Class members are private by default: class X { int
您可能关注的文档
- A companion to Chapter 9 by Lisa Patel Stevens.ppt
- a course of lectures.ppt
- A Dialogue in the Hospital.ppt
- a doctor.ppt
- A Proposal for NAEFS 8-14-day Forecasts.ppt
- A+标准制定的背景.ppt
- A.B.L.M.C.C HISTORY PORJECT.ppt
- a.归纳本文的情节发展步骤。.ppt
- A={4,5,6,8}B={3,5,7,8}C={5,8}.ppt
- AAA EVAR手术病例.ppt
- Chapter 9The Art of Intrusion Detection.ppt
- Chapter 9The Normal Distribution.ppt
- Chapter 9TRAP Routines andSubroutines.ppt
- Chapter Extension 7.ppt
- Chapter Four.ppt
- Chapter FourteenThe sixties and seventies.ppt
- Chapter Nine Checking Out.ppt
- Chapter Seven.Overview of Chapter 7.PPT
- Chapter10Operational Amplifier Applications.ppt
- Chapter15 精确模型.ppt
文档评论(0)