What is C++, Features, Applications of C++
Introduction to C++
C++ is a general-purpose, imperative, and most widely used programming language developed by Danish scientist Bjarne Stroustrup in 1979 at Bell Labs in Murray Hill, New Jersey, as an amplification or extension of the C programming language to include object-oriented programming features.
It has machine-independent and platform-dependent features. C++ is widely used for competitive programming due to its accuracy and complexity features. C++ programming language runs on many platforms such as Windows, Linux, Unix, Mac, Etc.
C++ is a statically typed, compiled, case-sensitive language that supports procedural-oriented and object-oriented programming.
Technically, C++ is considered a middle-level language since it combines high-level and low-level language features.
Features of C++
The following are the features and key points of the C++ programming language.
· Simple:
· Machine Independent but Platform Dependent:
· Mid-level language:
· Rich library support:
· Speed of execution:
· Pointer and direct Memory-Access
· Object-Oriented
· Compiled Language:
Structure of C++:
1. Documentation:
§ The documentation section is used to write the comments on the program. It may also be used to describe the purpose of the program that is going to be done. The comments written in the documentation section will not get executed, and these lines of code are not yet compiled.
§ We use ‘ // ‘ for single line comments and we also use ‘/* . . . . . . . . . . . . . . . . . . . . . . . */ ‘ for multi-line comments.
2. Linking Section:
o The link section within it consists of two main parts. They are as shown below:
§ Header Files
§ Name Spaces
§ Header Files: Generally, the software includes diverse programming factors like built-in capabilities, lessons, keywords, constants, operators, etc. Which can be already defined inside the general C++ library.
§ To apply such pre-defined factors in a program, the precise header must be included inside the program.
§ This enables the programmer to apply widespread input, output, and error centres which are provided best via the standard streams described in <iostream>. These trendy streams process data as a circulate of characters; statistics are examined and displayed in a continuous flow. The streams defined in <iostream> are listed right here.
§ Name Spaces: A namespace grants the gathering of different substances like classes, objects, functions, additional C++ tokens, and so forth under a solitary name.
3. Definition Section:
§ It is used to pronounce a few constants and dole out some worth. In this part, anybody can characterize their datatype utilizing crude information types. In #define is a compiler order which tells the compiler at whatever point the message is found to supplant it with “Factorial\n”.
§ Typedef int K: this assertion lets the compiler know that at whatever point you will experience K supplant it by int, and as you have pronounced k as datatype, you can’t involve it as an identifier.
4. Global Declaration
§ In this section, we will declare the variables which need not be declared in every block of the function or method.
§ Whatever the variables declared in the global section it applies to the entire program.
5. Main section:
· The C++ Program will start compiling from this section. Generally, it has two significant areas called as declaration and executable section.
· The primary function lets the compiler know where to begin the program’s execution. The execution of the program starts with the principal capability. Every one of the explanations that are to be executed is written in the primary function. Main Section consists of the central part with parameters and the return values.
· There are also different kinds of tokens such as keywords, identifiers, literals operators, punctuators etc. There are a total of 95 keywords in the C++ programming language.
6.UserDefined Section:
§ In this section, we will include any other methods for which the complexity of the program is being reduced.
Example:
C++ Program:
//Documentation — C++ program to print the assigned number
#include <iostream> // linking section
Using namespace std;
int a=100; //global declaration
int main ()
{
// main section
Cout<< a;
return 0;
}//main
Output:
a=100
Applications of C++:
C++ finds varied usage in applications such as:
· Operating Systems & Systems Programming. e.g., Linux-based OS (Ubuntu etc.)
· Browsers (Chrome & Firefox)
· Graphics & Game engines (Photoshop, Blender, Unreal-Engine)
· Database Engines (MySQL, MongoDB, Redis etc.)
· Cloud/Distributed Systems