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

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

Computing Practice I

8th lecture, June 8, 2017

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

Martin J. Dürst

AGU

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

Today's Schedule

 

ミニテスト

 

Results of Previous Exercises

07A1 07B1 07C1 07C2 07C3
100 points 42 40 16 10 3
60 points 55 55 76 74 43
partial - - - - 17
errors 1 2 4 6 20
not submitted 1 2 3 9 16

07C3: 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)

 

Important Points for Member Functions

 

Conversion from Function to Member Function

 

Important Points for Constructors

 

C++ Header Files

 

今日の演習

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

 

次回までの準備

 

Glossary

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