C++ Features
C++ is a general-purpose programming language that evolved from the C language to include an object-oriented paradigm. It is a compiled and imperative language.

Object-Oriented Programming
Object-oriented programming language concepts:
- Class
- Objects
- Encapsulation
- Polymorphism
- Inheritance
- Abstraction
Class: A Class is a C++ building piece that leads to Object-Oriented programming. It is a user-defined data type with its own set of data members and member methods that can be accessed and used by setting up a class instance.
Objects: An Object is a recognizable thing that has certain qualities and behaviours. A Class's instance is an Object.
Example:
class Man
{
char name[20];
int id;
public:
void getdetails(){}
};
int main()
{
Man M1; // M1 is a object
}
Encapsulation: Encapsulation is the process of encapsulating data and information in a single entity. Encapsulation is described as the coupling of data and the functions that replace it in object-oriented programming.
Abstraction: One of the most fundamental features of object-oriented programming in C++ is data abstraction. Abstraction refers to revealing only the most important information while hiding the intricacies.
Polymorphism: Polymorphism refers to the fact that something exists in multiple forms. Polymorphism, in simple words, is the ability to present a message in multiple formats.
Inheritance: Inheritance refers to the ability of one class to inherit features and traits from another class. One of the most important features of object-oriented programming is inheritance.
Machine Independent
A C++ executable is not platform agnostic (compiled Linux applications will not run on Windows), but it is machine agnostic. Let us look at an example to understand this C++ feature better. Assume you've built a piece of code that runs on Linux, Windows, and Mac OS X, making C++ Machine Independent.
Simple
It is a simple language in the sense that programs can be broken down into logical units and fragments, and it supports a large number of library functions and data types. In addition, the C++ Auto Keyword makes things easier.
Example:
#inlcude<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
auto a_int = 10;
auto a_bool = false;
auto a_float = 30.43;
auto ptr = &a_float;
cout << typeid(a_bool).name() << "\n";
cout << typeid(an_int).name() << "\n";
return 0;
}
OUTPUT
b
i
High-Level Language
Unlike C, which is a mid-level programming language, C++ is a high-level language. Working with C++ is easy since it is a high-level language that is closely related to the human-comprehensible English language.
Popular
C++ may serve as a foundation for a variety of other programming languages that enable object-oriented programming. Simula 67, the first object-oriented language, lacked simulations, thus Bjarne Stroustrup chose to create C++.
Case-Sensitive
C++ is unmistakably a case-sensitive programming language. To take input from the input stream, for example, cin is utilized. But what if "Cin" doesn't work? Other languages, such as HTML and MySQL, are case-insensitive.
Compiler Based
Unlike Python, C++ is a compiler-based language. C++ applications are compiled, and their executable files are utilised to run them. As a result, C++ is a speedier programming language than Java and Python.
Dynamic Memory Allocation
The variables are assigned dynamical memory space when the programme executes in C++. Variables are allocated in the stack area within the functions. We often don't realise how much memory is necessary to store certain information in a defined variable until it's too late, and the quantity of required memory may be established at run time.
Memory Management
- In C++, we can allocate memory for a variable or array during runtime. There is a term dynamic memory allocation for this.
- The compiler handles the memory assigned to variables in other programming languages, such as Java and Python. In C++, however, this is not the case.
- In C++, dynamically allocated memory must be manually allocated when it is no longer needed.
Example:
#include <cstring>
#include <iostream>
using namespace std;
// Driver Code
int main()
{
int num = 5;
float* pt;
// Memory allocation of
// num number of floats
pt = new float[num];
for (int x = 0; x < num; ++x) {
*(pt + x) = x;
}
cout << "Display the GPA of students:"<< endl;
for (int x = 0; x < num; ++x) {
cout << "Student" << x + 1<< ": " << *(pt + x)<< endl;
}
// Pt memory is released
delete[] pt;
return 0;
}
OUTPUT:
Display the GPA of students:
Student1: 0
Student2: 1
Student3: 2
Student4: 3
Student5: 4
Multi-Threading
- Multitasking is a feature that allows your system to run two or more programmes at the same time. Multithreading is a specialised kind of multitasking. Multitasking may be divided into two types: process-based and thread-based.
- Process-based multitasking manages the execution of many applications at the same time. Thread-based multitasking is concerned with the multiprogramming of similar software parts.
- Multithreaded applications are not supported by C++ by default. Instead, it relies only on the operating system to provide this functionality.