tailieunhanh - Lecture Programming principles and practice using C++: Chapter 9 - Bjarne Stroustrup

This lecture presents language technicalities, mostly related to user defined types; that is, classes and enumerations. The main contents of this chapter include all of the following: Classes, enumerations, operator overloading. Inviting you refer. | Chapter 9 Technicalities: Classes, etc. Bjarne Stroustrup 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 . | Chapter 9 Technicalities: Classes, etc. Bjarne Stroustrup 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 = 7; // access var’s data member m int x = (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 mf(); //

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.