Eiffel Introduction Part V (1)

zhaozj2021-02-08  507

5 miscellaneous topics

5.1 Simple type in Eiffel

l Eiffel Includes Character, Boolean, INTEGER, REAL, and DOUBLE.

l The assignment of the simple object and equivalence checking is the same as usual, that is, the result of A: = B is a value to A, and A = B is represented by A and B. The value is true when the value is equal.

l Check the inequality, use A / = B

l Simplified objects don't need to be explicitly created.

l In short, simple type is Value Semantics.

5.2 Class Types

l Other types other than simple types are implemented via References (reference; also known as Pointers, pointers). Such objects need to be explicitly created.

l If b = void is true, then b does not refer to any reference object. If b / = void is true, then b refers to an object that has been created.

L thus, A: = B makes A, B refer to the same object (ie, a reference to the same object). In this case, the result of A = B is true.

Like, we use A / = B to check inequality.

There is also some ways (copy, is_equal) to enable the domain (field) of a reference object to another object, and can check if the two objects contain the same value.

l In short, Class Types uses the reference semantics.

5.3 General Categories

l Each category is inherited from category any, and category Any is inheriting from category.

l void This feature is in the beloved, so each category can be used.

The other important feature of the Larges General is IO. IO is declared as an STD_FILES type, providing convenient access to the input / output program (Routines).

l For example, IO.Readint reads an integer from standard input. The result of the read is placed in o.lastint. (It can be noted that Feature, which can be changed, and Feature that only inquires only the inquiry (ie, the state cannot be changed) is separated.)

5.4 variables and objects

l To let the variable B refer to an object, there are two ways:

1. Explicitly create B object: !! B.make

2. Assumpted to B with the object that has been created: !! a.make; b: = a

l Similarly, there are two ways to make B disengage (DETACH) to an object:

Explicit Detachment: B: = Void

2. Assign a VOID reference to B: A: = void; b: = a

转载请注明原文地址:https://www.9cbs.com/read-399.html

New Post(0)