Đang chuẩn bị liên kết để tải về tài liệu:
A Complete Guide to Programming in C++ part 33

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

A Complete Guide to Programming in C++ part 33. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | MEMBER OBJECTS 299 Has-A Relationship Data members belonging to one class can be objects of a different class. In our example the Account class we already made use of this feature. The name of the account holder is stored in a string type data member. An object of the Account class therefore has a string type member sub-object or member object for short. If a class contains a data member whose type is of a different class the relationship between the classes is referred to as a Has-A relationship. Calling Constructors When an object containing member objects is initialized multiple constructor calls are to be executed. One of these is the constructor for the complete object and the others are constructors for the member objects. The order of the constructor calls is significant in this case. First the member objects are created and initialized this then allows the constructor to create the whole object. Unless otherwise stated the default constructor will be called for each member object. The Constructors for the Sample Class Result The example on the opposite page defines a sample class called Result. In addition to a double type measurement the time of each measurement is recorded. For ease of reading the constructors were defined separately rather than as inline. The default constructor only sets the value of the measurement to 0. However initialization is complete since the default constructor is called for the member object time. Example Result current The default constructor for the member object time first sets the hours minutes and seconds to 0. Then the constructor for the Result class is called and a value of 0.0 is assigned to val. The other constructors can be used to initialize an object explicitly. Example Result temperature1 15.9 Current Time Result temperature2 16.7 14 30 35 Since the compiler has no information on the relation of initial values and member objects it first calls the default constructor for the member object time. Subsequently the .

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.