Đang chuẩn bị liên kết để tải về tài liệu:
A Closer Look at Classes

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

This module continues the discussion of the class begun in Module 8. It examines a number of class-related topics, including overloading constructors, passing objects to functions, and returning objects. It also describes a special type of constructor, called the copy constructor, which is used when a copy of an object is needed. Next, friend functions are described, followed by structures and unions, and the ‘this’ keyword. The module concludes with a discussion of operator overloading, one of C++’s most exciting features | Module 9 A Closer Look at Classes Table of Contents CRITICAL SKILL 9.1 Overload contructors.2 CRITICAL SKILL 9.2 Assign objects.3 CRITICAL SKILL 9.3 Pass objects to functions.4 CRITICAL SKILL 9.4 Return objects from functions.9 CRITICAL SKILL 9.5 Create copy contructors.13 CRITICAL SKILL 9.6 Use friend functions.16 CRITICAL SKILL 9.7 Know the structure and union.21 CRITICAL SKILL 9.8 Understand this.27 CRITICAL SKILL 9.9 Know operator overlaoding fundamentals.28 CRITICAL SKILL 9.10 Overlaod operators using member functions.29 CRITICAL SKILL 9.11 Overlad operators using nonmember functions.37 This module continues the discussion of the class begun in Module 8. It examines a number of class-related topics including overloading constructors passing objects to functions and returning objects. It also describes a special type of constructor called the copy constructor which is used when a copy of an object is needed. Next friend functions are described followed by structures and unions and the this keyword. The module concludes with a discussion of operator overloading one of C s most exciting features. 1 C A Beginner s Guide by Herbert Schildt CRITICAL SKILL 9.1 Overloading Constructors Although they perform a unique service constructors are not much different from other types of functions and they too can be overloaded. To overload a class constructor simply declare the various forms it will take. For example the following program defines three constructors Overload the constructor. include iostream using namespace std class Sample public int x int y Overload the default constructor. Sample x - y 0 ------------------------ Constructor with one parameter. Sample int i x y i -----------Overload the Sample constructor. Constructor with two parameters Sample int i int 1 x i y j int main Sample t invoke default constructor Sample tl 5 use Sample int Sample t2 9 10 use Sample int int cout t.x t.x t.y t.y n cout tl.x tl.x tl.y tl.y n cout t2.x t2.x t2.y t2.y n return 0 The .

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