Програмен език C++
(Поредица в списание"Коснос")
от
Проф. Процесор Аритметиков

1. Увод

2. Що е това обект

3. Основните типове данни

A. Термините в C++, които се срещат в лекции 1 - 3
4. Вход и изход

5. Функции на класа

B. Термините в C++, които се срещат в лекции 4 и 5
6. Цикли

7. Операторите в C++

8. Операторите за управление

9. Операторите за управление ІІ

9a. Два примера за замяна на break и continue с други оператори

C. Термините в C++, които се срещат в лекции 6, 7, 8 и 9
10. Пример за клас, който преставя комплексните числа

11. Функции с аргументи

12. Пример за клас, който преставя часа и минутите

 D. Термините в C++, които се срещат в лекции 10, 11 и 12
13. Аритметика за потребителски дефинираните типове

14. Връщане на стойност от функциите

15. Масиви (Arrays)

16. Масивите като променливи в класовете (Arrays as Instance Data)

E. Термините в C++, които се срещат в лекции 13, 14, 15 и 16
17. Масиви от обекти (Arrays of Objects)

18. Низове (Strings)

19. Библиотечни функции за стрингове

F. Термините в C++, които се срещат в лекции 17, 18 и 19
20. Масиви от стрингове (Arrays of Strings)

21. Структури (Structures)

22. Изброен тип и логически тип (enum and bool)

23. Отново за функциите

24. За функциите на класовете и малко повече

G. Термините в C++, които се срещат в лекции 20, 21, 22, 23 и 24
25. Замяна на функции или т.н. презаредени функции (Overloaded Functions)

26. Аргументи по подразбиране (Default Arguments)

27. Запазване на променливите (Storage Classes)

28. Статични променливи на класа (Static Members)

29. Предаване на аргументи по връзка (Reference Arguments)

30. Връщане на стойност по връзка (Returning by Reference)

H. Термините в C++, които се срещат в лекции 25, 26, 27, 28, 29 и 30
31. Конструктори (Constructors)

32. Аргументи на конструктора (Constructor Arguments)

33. Едноаргументният конструктор (The One-Argument Constructor)

34. Масивите като променливи на класовете (Arrays as Instance Data)

35. Копиращите конструктори (Copy Constructors)

36. Използване на копиращите конструктори

37. Постоянни обекти (const Objects)

I. Термините в C++, които се срещат в лекции 31, 32, 33, 34, 35, 36 и 37
38. Визуализиране на конструкторите и деструкторите или за запазване на променливите

39. Презареждане на бинарните аритметични оператори (Overloading Binary Arithmetic Operators)

40. Презареждане на другите бинарни оператори

41. Презареждането на унарните оператори (Overloading Unary Operators)

42. Превръщане на обекти от потребителски класове в такива от предефинираните типове (Conversion from Objects to Basic Types)

43. Превръщането на обекти от различни класове един в друг (Conversions Between Classes)

44. Презареждане на оператора за присвояване (Overloading the Assignment Operator, =)

45. Презареждане на оператора за индекс (Overloading the Subscript Operator, [])

.
( вижте другите учебни материали )
.
[ това е поредица от учебни материали по програмния език C++ от списание “Коснос” http://www.kosnos.com ]
C++ Programming language    Програмен език C++  Програмен език С++
Why Do We Need OOP Procedural Languages Division into Functions Problems with Structured Programming The Object-Oriented Approach
OOP: An Approach to Organization, Not Details Features of Object-Oriented Languages States and Abilities
Classes Inheritance Reusability Creating New Data Types Polymorphism and Overloading
C++ and C Inputting the Data Displaying the Data
What Are the Objects? Syntax of the Class Specification Variable Declarations
Functions Public and Private Basic C++ Data Types Characters Assignment Operator Escape Sequences Integers Unsigned Integers Floating Point Whitespace
Comments Introduction to Input/Output Output to the Screen String Constants Formatting Output New Lines Not Automatic Escape Sequences The endl Manipulator Input from the Keyboard Stream I/O Old-Style C I/O Member Functions Initializing the Data Displaying Data
Arithmetic Operators Increment and Decrement Operators Specifying a Class Creating and Interacting with Objects Creating Objects from a Class Specification Sending Messages to Objects
The IOSTREAM.H Header File Preprocessor Directives Other Header Files
The main() Function Program Organization
Loops True and False Values Relational Operators while Loops do Loops for Loops Nested Loops Logical Operators Precedence
Simple Decisions The if Statement The if…else Statement Test Expression Nested if…else Statements Improving the Hot Dog Program with if
Advanced Decisions The else if Construction Fine-Tuning Loops The break Statement The continue Statement The switch Statement Improving the Hot Dog Program with switch The Conditional Operator
A class to Represent Time Values Assignment Statements with Objects More Manipulators: Formatting Leading Zeros
Function Arguments Sending a Message with an Argument
Writing the Member Function The set() Member Function with Arguments Arguments of Any Type
Other Uses for Functions Passing by Value
Arithmetic For User-defined Types
Access to Private Data Nonautomatic Conversions Calling Each Other
Function Return Values The return Statement Creating Automatic Variables The Stack Nameless Automatic Variables Returning by Value
Library Functions
ARRAYS AND STRINGS
Array Fundamentals Defining an Array Array Elements Accessing Array Elements Initializing Array Elements Multidimensional Arrays Danger: Index Out of Range
Arrays as Instance Data
Library Function getche() The  Key Postfix Increment Operators
Arrays of Objects Defining an Array of Objects New Syntax for Access
Strings String Variables String Constants Improved String I/O Using const Variables Eating Extra Characters String I/O External Variables
String Library Functions Library Functions for Strings Finding String Lengths Copying Strings Appending Strings Comparing Strings
Library Functions
Data Conversions Appending Assignment Wrapping
Arrays of Strings Syntax of Arrays of Strings Arrays of Empty Strings Arrays of Initialized Strings The stricmp() Function Arithmetic Assignment Operators
Structures Specifying a Structure Defining Structure Variables Accessing Structure Members Initializing Structure Variables Structure Usage Structures versus Classes
enum and bool Enumerated Data Types Specifying an Enumerated Type Creating and Using Enumerated Variables The bool Keyword
FUNCTIONS
Function Declaration Function Calls Function Definitions Arguments Return Values Function Declarations Arguments Functions Called from main()
Functions Called from Member Functions
Standalone Member Functions Inline Functions Specifying an Inline Function When Should You Inline a Function? Member Functions Defined Within a Class
Member Functions Defined Outside a Class The Scope Resolution Operator Macros
Overloaded Functions Need for Function Overloading How Does It Know? A Member Function Example
Default Arguments The cin.getline() Function Storage Classes Declarations and Definitions Two Kinds of Declarations Lifetime and Visibility Automatic Variables
Register Variables Blocks External Variables External Variables and Multiple Files External Variables in the Doghouse Local Static Variables The Storage Class Table Visiblity of Instance Data Lifetime of Instance Data
Static Members Static Member Data Creating Static Data Accessing Static Data Static Functions
Reference Arguments Passing by Value Passing by Reference A Reference Is a Different Name Standalone References Advantages of Passing by Reference
Returning by Reference Setting an Object to a Value
CONSTRUCTORS
Introducing Constructors Initialization Creation od Objects Destructors Constructors and Destructors in Action Same Name as the Class No Return Value
Initializing Variables Initialization List Default Constructor
Constructor Arguments “Calling” the Constructor A No-Argument Constructor
The One-Argument Constructor Conversions
Arrays as Instance Data Array Sized with Constant Array Sized with External const Initializing Member Variables Instance Data Initialization Initialization Is Not Assignment Arrays Sized at Compile Time The enum Hack Static Constant Variables Initializing a Member Array
Copy Constructors Copying Variables Equivalent Syntax Copying Objects The Default Copy Constructor const for Function Arguments
Passing by Reference Passing by Value Argument Must Be Passed by Reference Argument Should Be const
Initialization List A Variation on strcpy() Other Reasons for Using Copy Constructors Copy Constructor Invoked in Pass by Value Passing by Value Creates a Copy Why the Copy Constructor Must Use a Reference Argument Copy Constructor Invoked in Return by Value
const Objects const Functions
Visualizing Construction and Destruction Variables in main() Passing by Value Local Variables
OPERATOR OVERLOADING
Overloading Binary Arithmetic Operators Why Overload Operators You Could Do It with Functions You Can’t Overload Everything The operatorX() Function Arguments Return Value Other Binary Arithmetic Operators
Overloading Other Binary Operators Relational Operators Passing the Argument by const Reference Assignment Operators Avoiding Temporary Objects
Overloading Unary Operators Prefix Version of Operator ++ Postfix Version of Operator ++ The Unary Minus Operator
Conversion from Objects to Basic Types Type Casting: Conversion for Basic Types Conversion Function Invoked Automatically
Casting for Clarity A Static Constant The static_cast Approach
Conversions Between Classes
Overloading the Assignment Operator (=) Syntax of the Overloaded Assignment Operator A Simple Assignment Operator Example An Assignment Operator That Allows Chaining
Overloading the [ ] Operator Access with access() Function One Size Fits All Access with Overloaded [ ] Operator
Fine-Tuning Overloaded Operators Constant Arguments Constant Functions Constant Overloaded Operators Adding Constant airtime Objects Return Values Returns from Assignment Operators The Amazing *this Object The += Operator Revisited The Increment Operator Revisited
INHERITANCE
Introduction to Inheritance Reusability Rewriting Code Function Libraries Class Libraries Inheritance and Program Design Composition: A “Has a” Relationship
Inheritance: A “Kind of” Relationship Not Exactly a Family Tree Inheritance Syntax Inheriting Attributes Accessing Base Class Data Calling a Base Class Function Function Overloading in Base and Derived Classes
Class Hierarchy Abstract Classes Reusability
The Base Class Constructor The protected Access Specifier Functions That Aren’t Inherited
Constructors and Inheritance The Great Chain of Constructors When Are Derived Class Constructors Necessary?
No Arguments Arguments The Initializer List Adding Functionality to the Derived Class Constructor
Access Control Access Review Keeping Data Private A Stack Example Public and Private Inheritance The Compiler and Public Inheritance Private Inheritance
The Compiler and Private Inheritance Protected Inheritance
Grandparents Deriving foreman from laborer
Composition A safearay Object in a Stack Class
Multiple Inheritance Ambiguous Subobjects Virtual Base Classes Composition to the Rescue
POINTERS
Addresses and Pointers Addresses (Pointer Constants) The Address of Operator & Pointer Variables Pointers to Basic Types Syntax Quibbles Pointers Must Have a Value Pointers to Objects Accessing the Variable Pointed To Pointer to void
Pointers, Arrays, and Functions Pointers and Arrays Array Elements and Pointer Notation Pointer Constants and Pointer Variables Pointers and Functions Passing Simple Variables Passing Arrays as Arguments
Pointers and Strings Pointers to String Constants Strings as Function Arguments Copying a String Using Pointers Library String Functions Arrays of Pointers to Strings Membership Access Operator (->)
Memory Management with new and delete The new Operator The delete Operator A String Class That Uses new
Creating Objects with new An Array of Pointers to Objects
this and const The this Pointer Accessing Member Data with this Using this for Returning Values Pointers and the const Modifier const Variables Two Places for const Function Arguments and const Returning const Values Returning *this by Reference
A Linked List Class A Chain of Pointers Adding an Item to the List Displaying the List Contents Self-Containing Classes Augmenting the linklist Program Containers
A Sorted Array Class Inserting Objects in Sorted Order Searching for a Specific Element The Binary Search Constructors Used to Initialize Array
VIRTUAL FUNCTIONS AND FRIEND FUNCTIONS
Introduction to Virtual Functions Polymorphism Normal Member Functions Accessed with Pointers Virtual Member Functions Accessed with Pointers Late Binding Arrays of Pointers to Objects Examples of Virtual Functions Virtual Functions Initializing the Array Virtual Functions and Constructors
Decoupling with Polymorphism Passing References Passing Pointers
Abstract Classes and Virtual Destructors Abstract Classes Pure Virtual Functions Abstract Classes and Pure Virtual Functions Pure Virtual Functions with Bodies
Virtual Destructors Is the Derived Class Destructor Executed? When Do You Use Virtual Functions?
Runtime Type Identification
Friend Functions The “Left-Side” Problem No Problem on the Right Not So Easy on the Left Friends to the Rescue Friends for Functional Notation Friends as Bridges
Friend Classes Interclass Communication Accessing Private Members in a Previously Defined Class Accessing Private Members in a Not Yet Defined Class Pointers in Interclass Communication
Nested Classes and Static Member Data Nested Classes Communication Between Nested Classes
STERAMS AND FILES
Stream Classes Advantages of Streams The Stream Class Hierarchy The ios Class Formatting Flags Manipulators Functions The istream Class The ostream Class The iostream and the _withassign Classes Predefined Stream Objects Stream Errors Error-Status Bits Inputting Numbers Too Many Characters No-Input Input Inputting Strings and Characters All-Character Input
Disk File I/O with Streams Formatted File I/O Writing Data Reading Data Strings with Embedded Blanks Detecting End-of-File Character I/O Direct Access to the streambuf Object Binary I/O Object I/O Writing an Object to Disk Reading an Object from Disk Compatible Data Structures I/O with Multiple Objects The stream Class The open() Function The Mode Bits
File Errors and File Pointers Error Handling in File I/O Reacting to Errors Analyzing Errors File Pointers Specifying the Position Specifying the Offset The tellg() Function
File I/O Using Member Functions Objects That Read and Write Themselves Classes That Read and Write Themselves Static Functions Size of Derived Objects
Using the typeid() Function Code Number for Object Type No Homemade Objects
Overloading the << and >> Operators Overloading for cout and cin Overloading for Files Overloading for Binary I/O
Memory as a Stream Object Fixed Buffer Size The ostrstream Object Input Memory Streams Universality File Pointers Dynamic Buffer Size
Printer Output and Other Refinements Command-Line Arguments Printer Output Redirection Using the redir Program Redirecting Output Redirecting Input Redirecting Input and Output Redirection and the _withassign Classes
TEMPLATES, EXCEPTIONS, AND MORE
Function Templates A Simple Function Template Function Template Syntax What the Compiler Does Function Templates with Multiple Arguments Template Arguments Must Match More Than One Template Argument Why Not Macros?
Class Templates Class Name Depends on Context A Linked List Class Using Templates Storing User-Defined Data Types
Exceptions Why Do We Need Exceptions? Exception Syntax Specifying the Exception Class Throwing an Exception The try Block The Exception Handler (catch Block) The Sequence of Events
Multiple Exceptions Exceptions with the Distance Class Exceptions with Arguments Specifying Data in an Exception Class Initializing an Exception Object Extracting Data from the Exception Object The xalloc Class Exception Notes Destructors Called Automatically Termination Oriented Function Nesting Can’t Return to Throw Point
Explicit Casts, typedef, and the Operator Explicit Casts Static Casts Dynamic Casts Const Casts Reinterpret Casts The typedef Specifier Pointers and typedef Classes and typedef  More Portable Code Templates and typedef Overloading the Function Operator
The Standard string Class Header Files Constructors and Operators Member Functions The insert(), remove(), and replace() Member Functions The find() Member Function The find_first_of() Member Function The substr() Member Function Passing string Objects as Arguments The copy() Member Function
The c_str() Member Function Arrays of string Objects The compare() Member Function Get Ready for the STL
Multifile Programs Reasons for Multifile Programs Class Libraries Public Components Private Components Organization and Conceptualization How to Create a Multifile Program Header Files Directory Multiple Files Namespaces Declaring Namespaces Accessing Elements from Another Namespace
A Very-Long-Numbers Example Numbers as Strings The Class Specifier
THE STANDARD TEMPLATE LIBRARY
Introduction to the STL Containers Sequence Containers Associative Containers Member Functions Abstract Data Types Algorithms Iterators Potential Problems with the STL
Algorithms The find() Algorithm Header Files Ranges The count() Algorithm The sort() Algorithm The search() Algorithm The merge() Algorithm Function Objects User-Written Functions in Place of Function Objects Boolean Type Adding _if to Algorithms The for_each() Algorithm The transform() Algorithm
Sequential Containers Vectors Member Functions push_back(), size(), and Operator [ ] Member Functions swap(), empty() back(), and pop_back() Member Functions insert() and erase() Lists Member Functions push_front(), front(), and pop_front Member Functions reverse(), merge(), and unique() Deques
Iterators as Smart Pointers Ordinary Pointers Underpowered Iterators as an Interface Matching Algorithms with Containers Plugging the Cable into a Container
Plugging the Cables into the Algorithm Overlapping Member Functions and Algorithms Iterators at Work Data Access Data Insertion Algorithms and Iterators Specialized Iterators Iterator Adapters Reverse Iterators Insert Iterators Stream Iterators The ostream_iterator Class The istream_iterator Class Associative Containers Sets and Multisets Maps and Multimaps Iterating Through Maps Pairs The [ ] Operator Hash Table Versions Storing User-Defined Objects A Set of person Objects Necessary Member Functions Ordering Just Like Basic Types
Function Objects Predefined Function Objects Writing Your Own Function Objects Different Criteria for Sorting Binding: Providing Values to Function Objects