It was designed with a bias toward system programming and embedded, resource-constrained and large systems, with performance, efficiency and flexibility of use as its design highlights.
Data Types
Set of values together with set of operations called data type.C++ data types classified into three categories: 1.Simple data type 2.Structured data type 3.Pointers
Integral Data Types
Floating-Point Data Types :
Standard Library
The C++ Standard Library can be categorized into two parts:
The Standard Function Library: This library consists of general-purpose,stand-alone functions that are not part of any class. The function library is inherited from C. The Object Oriented Class Library: This is a collection of classes and associated functions.
Variable Types
Operators in C++
1.Arithmetic Operators.
II.Relational Operators
III.Logical Operators
IV. Bit-wise Operators
V.Assignment Operators
VI.Misc Operators
Standard I/O Devices
Use iostream to extract (receive) data from keyboard and send output to the screen IOstream contains definitions of two types:
Basic IOstream variables:
cin and cout
To use cin and cout, the preprocessor directive #include must be used
The declaration is similar to the following C++ statements:
Input stream variables: type istream
Output stream variables: type ostream
FUNCTIONS
What are Functions?
A function is a group of statements that together perform a task. Every C program has at least onefunction, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions.
Arrays
1) Predefined standard library functions – These are available to anyone who writes a C++ program. This saves the programmer’s time from writing own functions. They are completely debugged, efficient and always produce a precise output. The important contribution of the system-supplied functions is that they provide clarity to the program because they do not have to be redefined. It reduces the source code, which saves time of the programmer.
2) User Defined functions – C++ language allows additional functions besides the built-in functions called the user-defined function. It allows programmers to define their own functions. The programmer must code the logic of this type. In order to do so, a declaration is needed.
Enumeration Data Type
An enumeration is a distinct type whose value is restricted to a range of values (see below for details), which may include several explicitly named constants (“enumerators“). The values of the constants are values of an integral type known as the underlying type of the enumeration.
Data types:
C++ simple data types:
C++ structured data types:
C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
C++ Arrays in Detail
Structures
Structure is a collection of variables of different data types under a single name. It is similar to a class in that, both holds a collection of data of different data types.
How to define a structure variable?
Once you declare a structure person as above. You can define a structure variable as:
How to define a structure variable?
Once you declare a structure person as above. Person Jack; Here, a structure variable Jack is defined which is of type structure person. When structure variable is defined, only then the required memory is allocated by the compiler.
How to access members of a structure?
The members of structure variable is accessed using a dot (.) operator. Suppose, you want to access salary of structure variable Jack and assign it 98000 to it.
Jack.age=98000;
Strings
The String Class in C++
The standard C++ library provides a string class type that supports all the operations mentioned above, additionally much more functionality. We will study this class in C++ Standard Library
Pointers
What Are Pointers?
A pointer is a variable whose value is the address of another variable. Like any variable or constant, you must declare a pointer before you can work with it.
Using Pointers in C++:
There are few important operations, which we will do with the pointers very frequently. (x) we define a pointer variables (y) assign the address of a variable to a pointer and (z) finally access the value at the address available in the pointer variable. This is done by using unary operator * that returns the value of the variable located at the address specified by its operand.
C++ Pointers in Detail
I/O Library Header Files
Inheritance
Derive quality and characteristics from parents or ancestors. Like you inherit features of your parents.
Types of Inheritance:
Polymorphism
Polymorphism is one of the crucial feature of c++ it simply means one name and multiple forms.The function overloading and operator overloading is known as compile time Polymorphism / static Polymorphism.
Data Abstraction
Data abstraction refers to, providing only essential information to the outside world and hiding their background details, i.e., to represent the needed information in program without presenting the details.Data abstraction is a programming (and design) technique that relies on the separation of interface and implementation.
Data Encapsulation
Data encapsulation is a mechanism of bundling the data, and the functions that use them and data abstraction is a mechanism of exposing only the interfaces and hiding the implementation details from the user.C++ supports the properties of encapsulation and data hiding through the creation of user-defined types, called classes. We already have studied that a class can contain private, protected and public members.