1 / 9

5.3 型 (1)型の種類

5.3 型 (1)型の種類. ① あらかじめ用意された基本となる型   例:整数、浮動小数点、文字型、文字列、     倍精度浮動小数点、 10 進数 ②型と型構成の宣言   例: C の構造体、 Visual BASIC のユーザ型宣言 ③演算子と処理の定義   例: C# の Operator 宣言. (2)配列. 同じデータ型のデータの集まり ①要素の型 ②配列の大きさ(上限添字と下限添字) ③多次元も可能 ④動的な配列の大きさの宣言   例: Visual Basic の Redim Java や C# での new による生成.

rangle
Download Presentation

5.3 型 (1)型の種類

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 5.3 型(1)型の種類 ①あらかじめ用意された基本となる型   例:整数、浮動小数点、文字型、文字列、     倍精度浮動小数点、10進数 ②型と型構成の宣言   例:Cの構造体、Visual BASICのユーザ型宣言 ③演算子と処理の定義   例:C#のOperator宣言

  2. (2)配列 同じデータ型のデータの集まり ①要素の型 ②配列の大きさ(上限添字と下限添字) ③多次元も可能 ④動的な配列の大きさの宣言   例:Visual Basicの Redim JavaやC#での newによる生成

  3. (3)構造体 異なるデータの集まり(構造体、ユーザ定義体など) ①要素の名前 ②要素の型 例: Pascal type codedata = record op, opr1, opr2:integer end; C typedef struct { int op, opr1,opr2;} codedata; Basic type codedata op as integer opr1 as integer opr2 as integer end type

  4. 再帰的な型 例:2分木の定義 typdef struct Binary_Tree{ int Val; struct Binary_Tree *Left, *right;}Tree;

  5. (4)プログラム実行時の型の付与 ① BASIC(VBを含む)、Lispなどのインタプリタでは、実行時の値によって型が決まる。 ② Adaの型引数(正確には実行時ではないが型変数に近い)

  6. (5)型の検査(type checking) プログラム中で型の整合性が取れているかをチェックすること。 ① Pascalでは厳密な型チェックを行う。 ② インタプリタを前提とする言語では、この型チェックによって自動的に型変換を行うことが多い。 ③ FORTRAN や C では、型の検査はそれほど厳密ではない。

  7. Cの左辺値(left value)と右辺値(right value) 代入の左辺は左辺値でなければならない。   左辺値:変数名またはポインタ値(配列はポインタ) 【Lispでは】  基本的に引数に対して Eval を行うかどうか (setq A B) A← eval(B)

  8. (6)型の等価(type equivalence) 型の等価は、同じ基本型から出発して同じ構成法で作成された型を等価とする考え方。 ① 構造等価(structural equivalence) 名前が異なるが構造が同じ 【例】 typedef float*type0; typedef type0 t1[10]; typedef float *t2[10]; ② 名前等価(name equivalence)  同じ型名だけが同じ型と判断(Pascal)

  9. (7)多重定義(overload) 2つ以上の実体に対して同じ名前を用いること 通常は引数の型が異なるものに対して同じ名前を用いる。 したがって、   ①同じ名前   ②同じ引数の個数   ③型の並びが同じ ものを特定の実体としてみなす。C#では、 int Add(int A, B){ return A+B;} float Add(float A, B) { return A+B;} は別の関数とみなされる。

More Related