142 bilgisayar programlama ii (c/c++) - gazi...

22
1 142 Bilgisayar Programlama II (C/C++) !" #$ % const & const %" & ( ) #$" friend friend ( * this + #$" new delete , " - .!" static (

Upload: truongnhan

Post on 07-Feb-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

1

����142 Bilgisayar Programlama II (C/C++)

� ������� �� ����������

� ���������������

���������� �������� ���!�" �

#��$�

� � ��%� const &���������const ����'���������

� ���%��" � �&��������(����������) ����#$���" �� friend '�������������friend (���*�

� this +������#$���" �

� new ���delete ���,���" ���� �-����.!����" �

� static (���������

Page 2: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

2

3

� ��%

� const ������������const������� ������������ �� ��������������������� ������

� this���������������������static �� � �������������������� �� ��

� new ���delete��� ����������� ���� ��� ����������� �� ��

#��$�

� � ��%� const &���������const ����'���������

� ���%��" � �&��������(����������) ����#$���" �� friend '�������������friend (���*�

� this +������#$���" �

� new ���delete ���,���" ���� �-����.!����" �

� static (���������

Page 3: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

3

5

const &���������const ����'���������

� � ���������������������������������� ����� ��� const ������������������������������ � �����������

� ����������� ����� ���� ���� ����� ����������������� !!��������"����const�������� ��������������� ��const � ���� �� � ��� ������ ��� �������������

6

const &���������const ����'���������

Page 4: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

4

7

const &���������const ����'���������

8

const &���������const ����'���������

Page 5: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

5

9

const &���������const ����'���������

10

const &���������const ����'���������

Page 6: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

6

11

const &���������const ����'���������

� #���� � ��������������������� ���������� $���� ��� � �� �� ��� ������

� ����� � ����������������� ���� � ��������������������� ��������� ��� � �� �� ���� ������ ����

� %����������� ������"�����"���� � ����������������������� � �����&'(� � ���� ����� ����

� %����������� ��������������� � ������������������&)(����� ���������� � � ��� �&*(�������

� +���� � ������� ���� ����� �� � �����&,�-(��������� �� ������������ � ����

� ����� � ����������� ����������&.(����������� � � �� � �������

12

const &���������const ����'���������

Page 7: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

7

13

const &���������const ����'���������

14

const &���������const ����'���������

Page 8: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

8

15

const &���������const ����'���������

� const��������= ���� � � �"������� � ���������

� const��������= ���� � � �"������� � ���������

#��$�

� � ��%� const &���������const ����'���������

� ���%��" � �&��������(����������) ����#$���" �� friend '�������������friend (���*�

� this +������#$���" �

� new ���delete ���,���" ���� �-����.!����" �

� static (���������

Page 9: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

9

17

���%��" � �&��������(����������) ����#$���" �

� ����������� � �����"� ��������������� � ���� ��� ��������������������� ��� ������������,�����������-�������

� /�����������AlarmClock"� ���������Time ������������� � ������

� AlarmClok"� ������������������������� ����� �Time�������������������������������� ����

18

���%��" � �&��������(����������) ����#$���" �

Page 10: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

10

19

���%��" � �&��������(����������) ����#$���" �

20

���%��" � �&��������(����������) ����#$���" �

���������������� ������

Page 11: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

11

21

���%��" � �&��������(����������) ����#$���" �

22

���%��" � �&��������(����������) ����#$���" �

� ������� ����������dateOfBirth��birthDate�� �������� ��dataOfHire ���hireDate �� �������� ���� ���������

���������������������

Page 12: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

12

23

���%��" � �&��������(����������) ����#$���" �

24

���%��" � �&��������(����������) ����#$���" �

������ ������� �� �������������������������������������� �������� ���� ���������

Page 13: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

13

#��$�

� � ��%� const &���������const ����'���������

� ���%��" � �&��������(����������) ����#$���" �� friend '�������������friend (���*�

� this +������#$���" �

� new ���delete ���,���" ���� �-����.!����" �

� static (���������

26

friend '�������������friend (���*�

� �������������� �"� ���� � �����"� �������"����������� �� ���� �������"� �������������0�����"����������������������

� ClassOne������� � ��� ����� ������ �ClassTwoClassOne�� ��������� � �� ���� ����

� 1������������� ��"� ����������� ���� �� ��� �� �������������������������

� 1������� ���� � ���"� �������������� ��������������� ��� ������,���� ��*������"*�����"���-

Page 14: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

14

27

friend '�������������friend (���*�

28

friend '�������������friend (���*�

Page 15: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

15

29

friend '�������������friend (���*�

� 1�������� � ������������� ����� ����������������������

30

friend '�������������friend (���*�

� 1�������� � ������������� ����� ����������������������

Page 16: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

16

#��$�

� � ��%� const &���������const ����'���������

� ���%��" � �&��������(����������) ����#$���" �� friend '�������������friend (���*�

� this +������#$���" �

� new ���delete ���,���" ���� �-����.!����" �

� static (���������

32

this +������#$���" �

� +��������������� � ������������������������������� � ������

Page 17: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

17

33

this +������#$���" �

#��$�

� � ��%� const &���������const ����'���������

� ���%��" � �&��������(����������) ����#$���" �� friend '�������������friend (���*�

� this +������#$���" �

� new ���delete ���,���" ���� �-����.!����" �

� static (���������

Page 18: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

18

35

new ���delete ���,���" ���� �-����.!����" �

� !!�new ���delete��� �������������� ���� ��� ������������� � �� �� ��

� new��� �������� ���� � �� ��� � ����� ������� delete��� ������ ��� � � ��������������� ���������������� ���� � �� ����� �����������

� 2� ��� �new ��� ���������timePtr������ ��� ������������ ����� � �� �������

� 2� ��� � ���� �������� �������

36

new ���delete ���,���" ���� �-����.!����" �

� 2� ��� ������*��������������������� ���� ���������������

Page 19: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

19

#��$�

� � ��%� const &���������const ����'���������

� ���%��" � �&��������(����������) ����#$���" �� friend '�������������friend (���*�

� this +������#$���" �

� new ���delete ���,���" ���� �-����.!����" �

� static (���������

38

static (���������

� ��������������������������������������������������� ���������������

� static � � ��������������������������������������������� �������� �������

� static �������"� ����"��� �� �������� static �������public*�private ��� �protected� ���� � ������

� Static � � ���������� ��"�������������� ����������������

Page 20: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

20

39

static (���������

��� ����������������������

��������������!� ����

40

static (���������

Page 21: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

21

41

static (���������

!���� ���� ������ �����"� �#�!��������������

42

static (���������

Page 22: 142 Bilgisayar Programlama II (C/C++) - Gazi Üniversitesiw3.gazi.edu.tr/~akcayol/files/CPPL8OOP.pdf · 1 142 Bilgisayar Programlama II (C/C++) ˘ˇ ˆ ˙ˇˆ ˝ ˆ ˛˚ˇ ˜ ˆ !

22

43

static (���������

�������$�������"� ��������������� ��

���� �� ��������������#�!������������������

44

static (���������