Đang chuẩn bị liên kết để tải về tài liệu:
Lecture note Data visualization - Chapter 12

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

In this chapter, the following content will be discussed: Object oriented programming, inheritance mechanism, polymorphism mechanism, basic class syntax, class members, default parameters, initializer list, the explicit constructor, constant member function. | Lecture 12 Recap Object Oriented Programming Inheritance Mechanism Polymorphism Mechanism Basic Class Syntax Class Members Default Parameters Initializer List The explicit Constructor Constant Member Function Separation of Interface and Implementation In C++, separating the class interface from its implementation is more common The interface lists the class and its members and describes what can be done to an object The implementation represents the internal processes by which the interface specifications are met If a class had many function members and these functions were nontrivial, having to write all the function definitions inside the class declaration would be unreasonable The more typical mechanism is to provide the member function declarations in the class declaration and then define them later, using a normal function syntax augmented with the class name and scope operator : : This mechanism separates the class interface from the class implementation Preprocessor Commands . | Lecture 12 Recap Object Oriented Programming Inheritance Mechanism Polymorphism Mechanism Basic Class Syntax Class Members Default Parameters Initializer List The explicit Constructor Constant Member Function Separation of Interface and Implementation In C++, separating the class interface from its implementation is more common The interface lists the class and its members and describes what can be done to an object The implementation represents the internal processes by which the interface specifications are met If a class had many function members and these functions were nontrivial, having to write all the function definitions inside the class declaration would be unreasonable The more typical mechanism is to provide the member function declarations in the class declaration and then define them later, using a normal function syntax augmented with the class name and scope operator : : This mechanism separates the class interface from the class implementation Preprocessor Commands The interface is typically placed in a file that ends with . h Source code that requires knowledge of the interface must #include the interface file, which here means that both the implementation file and the file that contains main have the #include directive Occasionally, a complicated project will have files that contain other files, and there is the danger that an interface might be read twice in the course of compiling a file. This action can be illegal. To guard against it, each header file uses the preprocessor to define a symbol when the class interface is read 1 #ifndef -IntCell-H- 2 #define -IntCell-H- 3 4 // A class for simulating an integer memory cell. 5 6 class IntCell 7 ( 8 public: 9 explicit IntCell( int initialvalue = 0 ); 10 int read( ) const; 11 void write ( int x ) ; 12 13 private: 14 int storedvalue; 15 }; 16 17 #endif Explanation of Example The symbol name, _Intcell_H_, should not appear in any other file; usually we construct it from the filename The first line of

Đã 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.