First steps towards C++:
Structures + Functions = Classes

(C++ の初歩: 構造体 + 関数 = クラス)

Computing Practice I

8th lecture, May 31, 2018

http://www.sw.it.aoyama.ac.jp/2018/CP1/lecture8.html

Martin J. Dürst

AGU

© 2005-18 Martin J. Dürst 青山学院大学

Today's Schedule

 

ミニテスト

 

Results of Previous Exercises

07A1 07B1 07C1 07C2 07C3
100 points 76 42 17 7 -
60 points 23 54 70 61 9
partial - - - - 15
errors - 2 6 16 23
not submitted 1 2 7 16 53

07C2/C3: Reuse functions in other functions!

 

Environment for C++ Exercises

 

C++ Overview

 

Applications of C++: Browsers

 

Purpose of Object-Orientation

(noun: object-orientation, adjective: object-oriented)

(not part of today's exercises:)

 

Class Definition

class class_name {
declarations of member variables public: declarations of constructors declarations of member functions };

 

Example of Class Definition

class Point {
double x, y;
public:
Point ();
Point (double new_x, double new_y);
void set_x (double new_x);
void set_y (double new_y);
double get_x ();
double get_y ();
};

(set_... and get_... functions are called setter and getter and used to implement encapsulation)

 

Member Functions: Important

 

Conversion from Function to Member Function

 

Important Points for Constructors

 

C++ Header Files

 

今日の演習

08B1/08C1/08C2 ではメインプログラムを提出プログラムの最後に #include

インデントについて: public:/private: は普通のインデントの半分

 

次回までの準備

 

Glossary

object-orientation
オブジェクト指向
class
クラス
member function
メンバ関数
object-oriented (programming) language
オブジェクト思考 (プログラミング) 言語
encapsulation
カプセル化
inheritance
(クラスの) 継承
polymorphism
多態性
member variables
メンバ変数
receiver
レシーバ
constructor
コンストラクタ
setter
セッタ
getter
ゲッタ