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

Absolute C++ (4th Edition) part 2. 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. . | Variables Expressions and Assignment Statements ii Assignment Statements In an assignment statement first the expression on the right-hand side of the equal sign is evaluated and then the variable on the left-hand side of the equal sign is set equal to this value. Syntax Variable Expression Examples distance rate time count count 2 In C assignment statements can be used as expressions. When used as an expression an assignment statement returns the value assigned to the variable. For example consider n m 2 The subexpression m 2 both changes the value of m to 2 and returns the value 2. Thus this sets both n and m equal to 2. As you will see when we discuss precedence of operators in detail in Chapter 2 you can omit the parentheses so the assignment statement under discussion can be written as n m 2 We advise you not to use an assignment statement as an expression but you should be aware of this behavior because it will help you understand certain kinds of coding errors. For one thing it will explain why you will not get an error message when you mistakenly write n m 2 when you meant to write n m 2 This is an easy mistake to make since and are on the same keyboard key. Lvalues and Rvalues Authors often refer to lvalue and rvalue in C books. An lvalue is anything that can appear on the left-hand side of an assignment operator which means any kind of variable. An rvalue is anything that can appear on the right-hand side of an assignment operator which means any expression that evaluates to a value. 12 C Basics Pitfall Uninitialized Variables uninitialized variable A variable has no meaningful value until a program gives it one. For example if the variable minimumNumber has not been given a value either as the left-hand side of an assignment statement or by some other means such as being given an input value with a cin statement then the following is an error desiredNumber minimumNumber 10 This is because minimumNumber has no meaningful value and so the entire expression

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.