TAILIEUCHUNG - Absolute C++ (4th Edition) part 61

Absolute C++ (4th Edition) part 61. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | Programming with Inheritance 607 When overloading the assignment operator in a derived class you normally use the overloaded assignment operator from the base class. To help understand the code outline we will give remember that an overloaded assignment operator must be defined as a member function of the class. If Derived is a class derived from Base then the definition of the overloaded assignment operator for the class Derived would typically begin with something like the following Derived Derived operator const Derived rightside Base operator rightSide The first line of code in the body of the definition is a call to the assignment operator of the Base class. This takes care of the inherited member variables and their data. The definition of the overloaded assignment operator would then go on to set the new member variables that were introduced in the definition of the class Derived. A complete example that includes this technique is given in the programming example Partially Filled Array with Backup later in this chapter. A similar situation holds for defining the copy constructor in a derived class. If Derived is a class derived from Base then the definition of the copy constructor for the class Derived would typically use the copy constructor for the class Base to set the inherited member variables and their data. The code would typically begin with something like the following Derived Derived const Derived Object Base Object probably more initializations The invocation of the base class copy constructor Base Object sets the inherited member variables of the Derived class object being created. Note that since Object is of type Derived it is also of type Base therefore Object is a legal argument to the copy constructor for the class Base. A complete example that includes a copy constructor in a base class is given in the programming example Partially Filled Array with Backup later in this chapter. Of course these techniques do not work unless you have a .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.