Absolute C++ (4th Edition) part 24

Absolute C++ (4th Edition) part 24. 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. . | Structures 233 Display A Structure with A Structure Member part 2 of 2 41 42 43 44 45 - endl it had a balance of endl return 0 46 uses iostream 47 void getCDData CDAccount theAccount 48 49 cout Enter account initial balance 50 cin 51 cout Enter account interest rate 52 cin cout Enter the number of months until maturity 54 cin 55 cout Enter the maturity date n 56 getDate 57 58 uses iostream 59 void getDate Date theDate 60 61 cout Enter month 62 cin 63 cout Enter day 64 cin 65 cout Enter year 66 cin 67 Sample Dialogue Enter account data on the day account was opened Enter account initial balance Enter account interest rate Enter the number of months until maturity 6 Enter the maturity date Enter month 2 Enter day 14 Enter year 1899 When the CD matured on 2-14-1899 it had a balance of 234 Structures and Classes INITIALIZING STRUCTURES You can initialize a structure at the time that it is declared. To give a structure variable a value follow it by an equal sign and a list of the member values enclosed in braces. For example the following definition of a structure type for a date was given in the previous subsection struct Date int month int day int year Once the type Date is defined you can declare and initialize a structure variable called dueDate as follows Date dueDate 12 31 2003 The initializing values must be given in the order that corresponds to the order of member variables in the structure type definition. In this example receives the first initializing value of 12 receives the second value of 31 and receives the third value of 2003. It is an error if there are more initializer values than struct members. If there are fewer initializer values than struct members the provided values are used to initialize data members in order. .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.