Основы языка программирования C++ с применением объектно-ориентированного программирования. Чернышов М.К. - 8 стр.

UptoLike

Составители: 

ɝɪɚɦɦɢɪɨɜɚɧɢɹ Microsoft C++ , Microsoft Visual C++ ɢ ɫɢɫɬɟɦɵ ɩɪɨɝɪɚɦ-
ɦɢɪɨɜɚɧɢɹ ɮɢɪɦɵ Borland International. Ⱦɚɥɶɧɟɣɲɢɣ ɦɚɬɟɪɢɚɥ ɜ ɞɚɧɧɨɦ
ɩɨɫɨɛɢɢ ɢɡɥɚɝɚɟɬɫɹ ɩɪɢɦɟɧɢɬɟɥɶɧɨ ɤ ɫɢɫɬɟɦɟ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Borland
C++. ɗɬɨ ɫɜɹɡɚɧɨ, ɩɪɟɠɞɟ ɜɫɟɝɨ, ɫ ɧɚɥɢɱɢɟɦ ɜ ɷɬɨɣ ɫɢɫɬɟɦɟ ɩɪɨɝɪɚɦɦɢɪɨ-
ɜɚɧɢɹ ɪɚɡɜɢɬɨɣ ɢɧɬɟɝɪɢɪɨɜɚɧɧɨɣ ɫɪɟɞɵ, ɨɛɴɟɞɢɧɹɸɳɟɣ ɬɟɤɫɬɨɜɵɣ ɪɟɞɚɤ-
ɬɨɪ, ɤɨɦɩɢɥɹɬɨɪ, ɪɟɞɚɤɬɨɪ ɫɜɹɡɟɣ (ɤɨɦɩɨɧɨɜɳɢɤ) ɢ ɨɬɥɚɞɨɱɧɵɟ ɫɪɟɞɫɬɜɚ.
2. ɇɚɱɚɥɶɧɵɟ ɫɜɟɞɟɧɢɹ ɨ ɹɡɵɤɟ C++
2.1. ɇɚɡɧɚɱɟɧɢɟ ɹɡɵɤɚ C++, ɢɫɬɨɪɢɱɟɫɤɢɟ ɫɜɟɞɟɧɢɹ
əɡɵɤ ɋɢ ɛɵɥ ɪɚɡɪɚɛɨɬɚɧ ɜ 70-ɟ ɝɨɞɵ ɤɚɤ ɹɡɵɤ ɫɢɫɬɟɦɧɨɝɨ ɩɪɨɝɪɚɦɦɢ-
ɪɨɜɚɧɢɹ. ɉɪɢ ɷɬɨɦ ɫɬɚɜɢɥɚɫɶ ɡɚɞɚɱɚ ɩɨɥɭɱɢɬɶ ɹɡɵɤ, ɨɛɟɫɩɟɱɢɜɚɸɳɢɣ ɪɟɚ-
ɥɢɡɚɰɢɸ ɢɞɟɣ ɩɪɨɰɟɞɭɪɧɨɝɨ ɢ ɫɬɪɭɤɬɭɪɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɢ ɜɨɡɦɨɠ-
ɧɨɫɬɶ ɪɟɚɥɢɡɚɰɢɢ ɫɩɟɰɢɮɢɱɟɫɤɢɯ ɩɪɢɟɦɨɜ ɫɢɫɬɟɦɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ.
Ɍɚɤɨɣ ɹɡɵɤ ɩɨɡɜɨɥɢɥ ɛɵ ɪɚɡɪɚɛɚɬɵɜɚɬɶ ɫɥɨɠɧɵɟ ɩɪɨɝɪɚɦɦɵ ɧɚ ɭɪɨɜɧɟ,
ɫɪɚɜɧɢɦɨɦ ɫ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟɦ ɧɚ Ⱥɫɫɟɦɛɥɟɪɟ, ɧɨ ɫɭɳɟɫɬɜɟɧɧɨ ɛɵɫɬɪɟɟ.
ɗɬɢ ɰɟɥɢ ɜ ɨɫɧɨɜɧɨɦ ɛɵɥɢ ɞɨɫɬɢɝɧɭɬɵ. Ȼɨɥɶɲɢɧɫɬɜɨ ɤɨɦɩɢɥɹɬɨɪɨɜ ɞɥɹ ɋɢ
ɧɚɩɢɫɚɧɵ ɧɚ ɹɡɵɤɟ ɋɢ. Ɉɩɟɪɚɰɢɨɧɧɚɹ ɫɢɫɬɟɦɚ UNIX ɬɚɤɠɟ ɩɨɱɬɢ ɩɨɥɧɨ-
ɫɬɶɸ ɧɚɩɢɫɚɧɚ ɧɚ ɋɢ. ɇɟɞɨɫɬɚɬɤɨɦ ɋɢ ɨɤɚɡɚɥɚɫɶ ɧɢɡɤɚɹ ɧɚɞɟɠɧɨɫɬɶ ɪɚɡɪɚ-
ɛɚɬɵɜɚɟɦɵɯ ɩɪɨɝɪɚɦɦ ɢɡ-ɡɚ ɨɬɫɭɬɫɬɜɢɹ ɤɨɧɬɪɨɥɹ ɬɢɩɨɜ. ɉɨɩɵɬɤɚ ɩɨɩɪɚ-
ɜɢɬɶ ɞɟɥɨ ɜɤɥɸɱɟɧɢɟɦ ɜ ɫɢɫɬɟɦɭ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɋɢ ɨɬɞɟɥɶɧɨɣ ɩɪɨ-
ɝɪɚɦɦɵ, ɤɨɧɬɪɨɥɢɪɭɸɳɟɣ ɧɟɹɜɧɵɟ ɩɪɟɨɛɪɚɡɨɜɚɧɢɹ ɬɢɩɨɜ, ɪɟɲɢɥɚ ɷɬɭ
ɩɪɨɛɥɟɦɭ ɥɢɲɶ ɱɚɫɬɢɱɧɨ.
ɇɚ ɨɫɧɨɜɟ ɋɢ ɜ 80-ɟ ɝɨɞɵ ɛɵɥ ɪɚɡɪɚɛɨɬɚɧ ɹɡɵɤ ɋɢ++, ɜɧɚɱɚɥɟ ɧɚɡɜɚɧ-
ɧɵɣ «ɋɢ ɫ ɤɥɚɫɫɚɦɢ». ɋɢ++ ɩɪɚɤɬɢɱɟɫɤɢ ɜɤɥɸɱɚɟɬ ɹɡɵɤ ɋɢ, ɤɨɬɨɪɵɣ ɞɨ-
ɩɨɥɧɟɧ ɫɪɟɞɫɬɜɚɦɢ ɨɛɴɟɤɬɧɨ-ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ. Ɋɚɛɨ-
ɱɚɹ ɜɟɪɫɢɹ ɋɢ++ ɩɨɹɜɢɥɚɫɶ ɜ 1983ɝ. ɋ ɬɟɯ ɩɨɪ ɹɡɵɤ ɩɪɨɞɨɥɠɚɟɬ ɪɚɡɜɢɜɚɬɶ-
ɫɹ, ɢ ɨɩɭɛɥɢɤɨɜɚɧɨ ɧɟɫɤɨɥɶɤɨ ɜɟɪɫɢɣ ɩɪɨɟɤɬɚ ɫɬɚɧɞɚɪɬɨɜ ɋɢ ɢ ɋɢ++.
Ɋɹɞɨɦ ɮɢɪɦ, ɩɪɨɢɡɜɨɞɹɳɢɯ ɩɪɨɝɪɚɦɦɧɨɟ ɨɛɟɫɩɟɱɟɧɢɟ, ɪɚɡɪɚɛɨɬɚɧɵ
ɤɨɦɩɢɥɹɬɨɪɵ ɞɥɹ ɋɢ ɢ ɋɢ++. ɋɢɫɬɟɦɵ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɮɢɪɦɵ Borland
International ɜɵɞɟɥɹɸɬɫɹ ɫɪɟɞɢ ɞɪɭɝɢɯ ɮɢɪɦ, ɩɪɟɠɞɟ ɜɫɟɝɨ, ɤɨɦɩɥɟɤɫɧɵɦ
ɩɨɞɯɨɞɨɦ ɤ ɪɚɡɪɚɛɨɬɤɟ ɩɪɨɝɪɚɦɦ. Ɉɧɢ ɩɪɟɞɫɬɚɜɥɹɸɬ ɫɨɛɨɣ ɢɧɬɟɝɪɢɪɨɜɚɧ-
ɧɭɸ ɫɪɟɞɭ ɪɚɡɪɚɛɨɬɱɢɤɚ, ɨɛɴɟɞɢɧɹɸɳɭɸ ɩɨɞ ɨɛɳɢɦ ɭɩɪɚɜɥɟɧɢɟɦ ɬɟɤɫɬɨ-
ɜɵɣ ɪɟɞɚɤɬɨɪ ɞɥɹ ɜɜɨɞɚ ɢɫɯɨɞɧɵɯ ɬɟɤɫɬɨɜ ɩɪɨɝɪɚɦɦ, ɤɨɦɩɢɥɹɬɨɪ, ɪɟɞɚɤɬɨɪ
ɫɜɹɡɟɣ ɢ ɧɚɛɨɪ ɨɬɥɚɞɨɱɧɵɯ ɫɪɟɞɫɬɜ. ȼ 1989ɝ. ɷɬɨɣ ɮɢɪɦɨɣ ɛɵɥɚ ɜɵɩɭɳɟɧɚ
ɫɢɫɬɟɦɚ Turbo C++, ɜɤɥɸɱɚɸɳɚɹ ɜ ɫɟɛɹ ɤɨɦɩɢɥɹɬɨɪ ɋɢ++, ɪɚɛɨɬɚɸɳɢɣ ɜ
ɨɩɟɪɚɰɢɨɧɧɨɣ ɫɢɫɬɟɦɟ MS DOS. ɋ 1992ɝ. ɜɵɩɭɫɤɚɸɬɫɹ ɫɢɫɬɟɦɵ Borland
C++, ɫɨɞɟɪɠɚɳɢɟ ɤɨɦɩɢɥɹɬɨɪɵ ɋɢ++ ɞɥɹ MS DOS ɢ MS WINDOWS, ɫ
1997ɝ. ɩɨɫɬɚɜɥɹɟɬɫɹ ɜɟɪɫɢɹ Borland C 5.0, ɫɨɞɟɪɠɚɳɚɹ ɤɨɦɩɢɥɹɬɨɪɵ ɋɢ++
ɞɥɹ MS WINDOWS, ɩɪɢɱɟɦ ɞɚɧɧɵɣ ɤɨɦɩɢɥɹɬɨɪ ɞɥɹ MS WINDOWS ɩɨ-
8
ɝɪɚɦɦɢɪɨɜɚɧɢɹ Microsoft C++ , Microsoft Visual C++ ɢ ɫɢɫɬɟɦɵ ɩɪɨɝɪɚɦ-
ɦɢɪɨɜɚɧɢɹ ɮɢɪɦɵ Borland International. Ⱦɚɥɶɧɟɣɲɢɣ ɦɚɬɟɪɢɚɥ ɜ ɞɚɧɧɨɦ
ɩɨɫɨɛɢɢ ɢɡɥɚɝɚɟɬɫɹ ɩɪɢɦɟɧɢɬɟɥɶɧɨ ɤ ɫɢɫɬɟɦɟ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Borland
C++. ɗɬɨ ɫɜɹɡɚɧɨ, ɩɪɟɠɞɟ ɜɫɟɝɨ, ɫ ɧɚɥɢɱɢɟɦ ɜ ɷɬɨɣ ɫɢɫɬɟɦɟ ɩɪɨɝɪɚɦɦɢɪɨ-
ɜɚɧɢɹ ɪɚɡɜɢɬɨɣ ɢɧɬɟɝɪɢɪɨɜɚɧɧɨɣ ɫɪɟɞɵ, ɨɛɴɟɞɢɧɹɸɳɟɣ ɬɟɤɫɬɨɜɵɣ ɪɟɞɚɤ-
ɬɨɪ, ɤɨɦɩɢɥɹɬɨɪ, ɪɟɞɚɤɬɨɪ ɫɜɹɡɟɣ (ɤɨɦɩɨɧɨɜɳɢɤ) ɢ ɨɬɥɚɞɨɱɧɵɟ ɫɪɟɞɫɬɜɚ.


2. ɇɚɱɚɥɶɧɵɟ ɫɜɟɞɟɧɢɹ ɨ ɹɡɵɤɟ C++
2.1. ɇɚɡɧɚɱɟɧɢɟ ɹɡɵɤɚ C++, ɢɫɬɨɪɢɱɟɫɤɢɟ ɫɜɟɞɟɧɢɹ

     əɡɵɤ ɋɢ ɛɵɥ ɪɚɡɪɚɛɨɬɚɧ ɜ 70-ɟ ɝɨɞɵ ɤɚɤ ɹɡɵɤ ɫɢɫɬɟɦɧɨɝɨ ɩɪɨɝɪɚɦɦɢ-
ɪɨɜɚɧɢɹ. ɉɪɢ ɷɬɨɦ ɫɬɚɜɢɥɚɫɶ ɡɚɞɚɱɚ ɩɨɥɭɱɢɬɶ ɹɡɵɤ, ɨɛɟɫɩɟɱɢɜɚɸɳɢɣ ɪɟɚ-
ɥɢɡɚɰɢɸ ɢɞɟɣ ɩɪɨɰɟɞɭɪɧɨɝɨ ɢ ɫɬɪɭɤɬɭɪɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɢ ɜɨɡɦɨɠ-
ɧɨɫɬɶ ɪɟɚɥɢɡɚɰɢɢ ɫɩɟɰɢɮɢɱɟɫɤɢɯ ɩɪɢɟɦɨɜ ɫɢɫɬɟɦɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ.
Ɍɚɤɨɣ ɹɡɵɤ ɩɨɡɜɨɥɢɥ ɛɵ ɪɚɡɪɚɛɚɬɵɜɚɬɶ ɫɥɨɠɧɵɟ ɩɪɨɝɪɚɦɦɵ ɧɚ ɭɪɨɜɧɟ,
ɫɪɚɜɧɢɦɨɦ ɫ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟɦ ɧɚ Ⱥɫɫɟɦɛɥɟɪɟ, ɧɨ ɫɭɳɟɫɬɜɟɧɧɨ ɛɵɫɬɪɟɟ.
ɗɬɢ ɰɟɥɢ ɜ ɨɫɧɨɜɧɨɦ ɛɵɥɢ ɞɨɫɬɢɝɧɭɬɵ. Ȼɨɥɶɲɢɧɫɬɜɨ ɤɨɦɩɢɥɹɬɨɪɨɜ ɞɥɹ ɋɢ
ɧɚɩɢɫɚɧɵ ɧɚ ɹɡɵɤɟ ɋɢ. Ɉɩɟɪɚɰɢɨɧɧɚɹ ɫɢɫɬɟɦɚ UNIX ɬɚɤɠɟ ɩɨɱɬɢ ɩɨɥɧɨ-
ɫɬɶɸ ɧɚɩɢɫɚɧɚ ɧɚ ɋɢ. ɇɟɞɨɫɬɚɬɤɨɦ ɋɢ ɨɤɚɡɚɥɚɫɶ ɧɢɡɤɚɹ ɧɚɞɟɠɧɨɫɬɶ ɪɚɡɪɚ-
ɛɚɬɵɜɚɟɦɵɯ ɩɪɨɝɪɚɦɦ ɢɡ-ɡɚ ɨɬɫɭɬɫɬɜɢɹ ɤɨɧɬɪɨɥɹ ɬɢɩɨɜ. ɉɨɩɵɬɤɚ ɩɨɩɪɚ-
ɜɢɬɶ ɞɟɥɨ ɜɤɥɸɱɟɧɢɟɦ ɜ ɫɢɫɬɟɦɭ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɋɢ ɨɬɞɟɥɶɧɨɣ ɩɪɨ-
ɝɪɚɦɦɵ, ɤɨɧɬɪɨɥɢɪɭɸɳɟɣ ɧɟɹɜɧɵɟ ɩɪɟɨɛɪɚɡɨɜɚɧɢɹ ɬɢɩɨɜ, ɪɟɲɢɥɚ ɷɬɭ
ɩɪɨɛɥɟɦɭ ɥɢɲɶ ɱɚɫɬɢɱɧɨ.
     ɇɚ ɨɫɧɨɜɟ ɋɢ ɜ 80-ɟ ɝɨɞɵ ɛɵɥ ɪɚɡɪɚɛɨɬɚɧ ɹɡɵɤ ɋɢ++, ɜɧɚɱɚɥɟ ɧɚɡɜɚɧ-
ɧɵɣ «ɋɢ ɫ ɤɥɚɫɫɚɦɢ». ɋɢ++ ɩɪɚɤɬɢɱɟɫɤɢ ɜɤɥɸɱɚɟɬ ɹɡɵɤ ɋɢ, ɤɨɬɨɪɵɣ ɞɨ-
ɩɨɥɧɟɧ ɫɪɟɞɫɬɜɚɦɢ ɨɛɴɟɤɬɧɨ-ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ. Ɋɚɛɨ-
ɱɚɹ ɜɟɪɫɢɹ ɋɢ++ ɩɨɹɜɢɥɚɫɶ ɜ 1983ɝ. ɋ ɬɟɯ ɩɨɪ ɹɡɵɤ ɩɪɨɞɨɥɠɚɟɬ ɪɚɡɜɢɜɚɬɶ-
ɫɹ, ɢ ɨɩɭɛɥɢɤɨɜɚɧɨ ɧɟɫɤɨɥɶɤɨ ɜɟɪɫɢɣ ɩɪɨɟɤɬɚ ɫɬɚɧɞɚɪɬɨɜ ɋɢ ɢ ɋɢ++.
     Ɋɹɞɨɦ ɮɢɪɦ, ɩɪɨɢɡɜɨɞɹɳɢɯ ɩɪɨɝɪɚɦɦɧɨɟ ɨɛɟɫɩɟɱɟɧɢɟ, ɪɚɡɪɚɛɨɬɚɧɵ
ɤɨɦɩɢɥɹɬɨɪɵ ɞɥɹ ɋɢ ɢ ɋɢ++. ɋɢɫɬɟɦɵ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɮɢɪɦɵ Borland
International ɜɵɞɟɥɹɸɬɫɹ ɫɪɟɞɢ ɞɪɭɝɢɯ ɮɢɪɦ, ɩɪɟɠɞɟ ɜɫɟɝɨ, ɤɨɦɩɥɟɤɫɧɵɦ
ɩɨɞɯɨɞɨɦ ɤ ɪɚɡɪɚɛɨɬɤɟ ɩɪɨɝɪɚɦɦ. Ɉɧɢ ɩɪɟɞɫɬɚɜɥɹɸɬ ɫɨɛɨɣ ɢɧɬɟɝɪɢɪɨɜɚɧ-
ɧɭɸ ɫɪɟɞɭ ɪɚɡɪɚɛɨɬɱɢɤɚ, ɨɛɴɟɞɢɧɹɸɳɭɸ ɩɨɞ ɨɛɳɢɦ ɭɩɪɚɜɥɟɧɢɟɦ ɬɟɤɫɬɨ-
ɜɵɣ ɪɟɞɚɤɬɨɪ ɞɥɹ ɜɜɨɞɚ ɢɫɯɨɞɧɵɯ ɬɟɤɫɬɨɜ ɩɪɨɝɪɚɦɦ, ɤɨɦɩɢɥɹɬɨɪ, ɪɟɞɚɤɬɨɪ
ɫɜɹɡɟɣ ɢ ɧɚɛɨɪ ɨɬɥɚɞɨɱɧɵɯ ɫɪɟɞɫɬɜ. ȼ 1989ɝ. ɷɬɨɣ ɮɢɪɦɨɣ ɛɵɥɚ ɜɵɩɭɳɟɧɚ
ɫɢɫɬɟɦɚ Turbo C++, ɜɤɥɸɱɚɸɳɚɹ ɜ ɫɟɛɹ ɤɨɦɩɢɥɹɬɨɪ ɋɢ++, ɪɚɛɨɬɚɸɳɢɣ ɜ
ɨɩɟɪɚɰɢɨɧɧɨɣ ɫɢɫɬɟɦɟ MS DOS. ɋ 1992ɝ. ɜɵɩɭɫɤɚɸɬɫɹ ɫɢɫɬɟɦɵ Borland
C++, ɫɨɞɟɪɠɚɳɢɟ ɤɨɦɩɢɥɹɬɨɪɵ ɋɢ++ ɞɥɹ MS DOS ɢ MS WINDOWS, ɫ
1997ɝ. ɩɨɫɬɚɜɥɹɟɬɫɹ ɜɟɪɫɢɹ Borland C 5.0, ɫɨɞɟɪɠɚɳɚɹ ɤɨɦɩɢɥɹɬɨɪɵ ɋɢ++
ɞɥɹ MS WINDOWS, ɩɪɢɱɟɦ ɞɚɧɧɵɣ ɤɨɦɩɢɥɹɬɨɪ ɞɥɹ MS WINDOWS ɩɨ-


                                   8