表达式与赋值语句.ppt
文本预览下载声明
* * 1-* Mixed-Mode Assignment Assignment statements can also be mixed-mode In Fortran, C, and C++, any numeric type value can be assigned to any numeric type variable In Java, only widening assignment coercions are done In Ada, there is no assignment coercion 1-* Summary Expressions Operator precedence and associativity Operator overloading Mixed-type expressions Various forms of assignment * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright ? 2009 Addison-Wesley. All rights reserved. ISBN 0-321-49362-1 Chapter 7 Expressions and Assignment Statements 表达式与赋值语句 孟小亮 QQ: 1920525866 1-* Chapter 7 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions Short-Circuit Evaluation Assignment Statements Mixed-Mode Assignment 1-* Introduction Expressions are the fundamental means of specifying computations in a programming language To understand expression evaluation, need to be familiar with the orders of operator and operand evaluation Essence of imperative languages is dominant role of assignment statements 1-* Arithmetic Expressions Arithmetic evaluation was one of the motivations for the development of the first programming languages Arithmetic expressions consist of operators, operands, parentheses, and function calls 1-* Arithmetic Expressions: Design Issues Design issues for arithmetic expressions Operator precedence rules? Operator associativity rules? Order of operand evaluation? Operand evaluation side effects? Operator overloading? Type mixing in expressions? 1-* Arithmetic Expressions: Operators A unary operator has one operand A binary operator has two operands A ternary operator has three operands 1-* Arithmetic Expressions: Operator Precedence Rules The operator precedence rules for expression evaluation define the order in which “adjacent” operators of different precedence levels are evaluated Typical precedence levels parentheses unary operators ** (if the language supports it
显示全部