C++ became designed via Bjarne Stroustrup in 1985 as an extension of the C programing language and it is one of the quickest languages of programming.
Compiling and executing this system:
There are a few steps that customers desire to observe in order that this system may be compiled:
1.Open a text editor and add the program code so that it can be executed.
2.When the code is added , save the file using an .cpp extension (exemple main.cpp)
3.In command prompt navigate to the location where the file is saved.
4. Add the following command to compile g++ name_of_the_file.cpp and then hit the enter key.
5.An executable file is generated when the code is compiled.
6.The result is diplayed as an output.
The Language:
C++ has essential componentsents
1.A direct mapping of hardware features provided primarily by the C subset.
2.Zero-overhead abstractions based on those mappings.
C++ consists of a maximum of C's syntax. Bjarne Stroustrup's model of Hello international program makes use of the C++ Standard Library to jot down a message to conventional output.
Here is the output.
Object garage:
Like in C, C++ helps 4 forms of reminiscence control.
1.Static storage duration objects.
2.Thread storage duration objects.
3.Automatic storage duration objects.
4.Dynamic storage duration objects.
Static storage duration objects
They are created before main() is entered and destroyed in the opposite order of advent after main() exits. The order of advent isn't always distinct through the stander (possibly there are a few policies described below) to permit implementations.
Static storage duration objects are initialized in two phases
1.Static initialization: is performed, and only after all static initialization is performed
2.Dynamic initialization: is performed
In static initialization, all objects are initialized with zeros; after that, all objects which have a constant initialization phase are initialized with the constant variables initialized with a literal or constexpr).Though it isn't always distinct withinside the trendy, the static initialization section may be finished at assemble time and stored withinside the information partition of the executable.
Dynamic initialization includes all object initialization done via a constructor or call (unless the function is marked with, in C++11). The dynamic initialization order is defined because of the order of declaration within the compilation unit (i.e. the same file). No guarantees are provided about the order of initialization between compilation units.
Thread storage duration objects
Variables of this sort are very almost like static storage duration objects. The main difference is that the creation time is just before thread creation and destruction is completed after the thread has been joined.
Automatic storage duration objects
The most common variable types in C++ are local variables inside a function or block, and temporary variables.
Local variables are created because the point of execution passes the declaration point. If the variable features a constructor or initializer this is often wont to define the initial state of the thing . Local variables are destroyed when the local block or function that they're declared in is closed.
Dynamic storage duration objects
Objects have a dynamic lifespan, they're going to be created directly with a call to new and destroyed explicitly with a call to delete. C++ supports malloc and free , from C, but these aren't compatible with new and delete. New returns an address to the allocated memory.
Objects
C++ introduces O-OP (object-oriented programming) features to C. It offers classes, which give the four features in O-OP and a few non O-OP languages
1.Abstraction
2.Encapsulation
3.Inheritance
4.Polymorphism
Encapsulation
Encapsulation is that the hiding of data to supply that data structures and operators are used as intended and to form the usage model more obvious to the developer. C++ provides the power to define classes and functions as its primary encapsulation mechanisms. Within a category , members are often declared as either public, protected, or private to explicitly enforce encapsulation. A public member of the category is accessible to any function. private member is accessible only to functions that are members of that class and to functions and classes explicitly granted access permission by the category ("friends"). A protected member is accessible to members of classes that inherit from the category additionally to the category itself and any friends.
Inheritance
Allows one data type to accumulate properties of other data types. Inheritance from a base class could also be declared as public, protected, or private. This access specifier determines whether unrelated and derived classes can access the inherited public and guarded members of the bottom class Only public inheritance corresponds to what's usually meant by "inheritance". The other two forms are much less frequently used. If the access specifier is omitted, a "class" inherits privately, while a "struct" inherits publicly. Base classes could also be declared as virtual, this is often called virtual inheritance
Allows one data type to acquire properties of other data types. Inheritance from a base class may be declared as public, protected, or private. This access specifier determines whether unrelated and derived classes can access the inherited public and protected members of the base class Only public inheritance corresponds to what is usually meant by "inheritance". The other two forms are much less frequently used. If the access specifier is omitted, a "class" inherits privately, while a "struct" inherits publicly. Base classes may be declared as virtual, this is called virtual inheritance
Polymorphism
Polymorphism enables one common interface for several implementations, and for objects to act differently under different circumstances. C++ supports several sorts of static (at compile-time) and dynamic (at run-time).
C++ standard library
The standard C++ library is it provides serval generic container, functions and others.
This library is present at the primary line of code. Example:
Implementations
GNU C++ Standard Library (libstdc++)
The library is a component of the GCC sources and released as GPLv3 with an exception to link closed source application when built with GCC . Current version is 11.
Microsoft C++ Standard Library (STL)
At CppCon 2019 on September 16th, 2019, Microsoft announced releasing their implementation of the C++ Standard Library (also referred to as the STL) as open source. It is hosted on GitHub and licensed under the Apache License 2.0 with LLVM Exception.
Apache C++ Standard Library
The Apache C++ Standard Library is another open source implementation. It was originally developed commercially by Rogue Wave Software and later donated to the Apache Software Foundation.[11] However, after quite five years without a release, the board of the Apache Software Foundation decided to finish this project and move it to Apache Attic.
LLVM C++ Standard Library
The LLVM project includes an implementation of the C++ Standard Library called libc++, dual-licensed under the MIT License and therefore the UIUC license. Since v9.0.0, it had been relicensed to the Apache License 2.0 with LLVM Exceptions.
Quote
C++ is a complex language which features a lot of things for you to discover. Once you are interested in it you can't bail. I know it's kind of hard but it takes time and practice. If u give it time and practice you will get where you want with C++
Gabriel Ricardo.
Sources:
Wikipedia