Introduction to C++ Language

What is C++?

1) C++ is a cross-platform language that can be used to create high-performance applications.
2) C++ was developed by Bjarne Stroustrup, as an extension to the C language.
3) C++ gives programmers a high level of control over system resources and memory.
4) The language was updated 4 major times in 2011, 2014, 2017, and 2020 to C++11, C++14, C++17, C++20.

Why learn C++?

1) C++ is one of the world's most popular programming languages.
2) C++ can be found in today's operating systems, Graphical User Interfaces, and embedded systems.
3) C++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs.
4) C++ is portable and can be used to develop applications that can be adapted to multiple platforms.
5) C++ is fun and easy to learn!
6) As C++ is close to C, C# and Java, it makes it easy for programmers to switch to C++ or vice versa.

Difference between C and C++ :

1) C++ was developed as an extension of C, and both languages have almost the same syntax.
2) The main difference between C and C++ is that C++ support classes and objects, while C does not.

Quickstart for C++ :

Let's create our first C++ file.
Open Codeblocks (you can open any other software as well) and go to File -> New -> Empty File.
Write the following C++ code and save the file as myfirstprogram.cpp (File -> Save)
    #include< iostream>
    using namespace std;
    int main()
    {
       cout << "Hello World!";
       return 0;
    }
Don't worry if you don't understand the code above. For now, focus on how to run the code.
In Codeblocks, it should look like this:
C Code
Then, go to Build > Build and Run to run (execute) the program. The result will look something to this:
Output Code
Congratulations! You have now written and executed your first C++ program.

Advantages of C++ :

  • C++ is an object-oriented programming language. It may be a collection of commands, which tell the pc to try to do “something.” This collection of commands is typically called C++ ASCII text files.
  • C++ could also be a problem-oriented language that’s much easier to use than the other low-level languages like binary coding. It takes much more space than low-level languages but it’s much easier to understand and learn.
  • C++ program has many advantages when it involves programming, All C++ program stand-alone files must use the foremost function to allow the program to start out up and motivate its functions.
  • C++ program can support unions and structures that are a mix of stand-alone and put-together files, It uses the standard C++ application mentioned as “.cpp”, C++ uses the reserved library word mentioned as “goto” that’s the same as Java’s continue, or break commands.
  • Disadvantages of C++ :

  • One major problem in C++ is when the info points to an equivalent thing from two different starting points, this causes a serious problem, the C++ program will still have involved problems within the coding.
  • C++ program can’t support garbage pickup, It doesn’t support Dynamic Memory Allocation, it’s not secure because it’s a pointer, friend function, and global variable and it’s no support for threads built-in.
  • It is used for platform-specific applications commonly.
  • C++ program is complex during a very large high-level program, C++ is employed for platform-specific application commonly, For the actual OS or platform, the library set is typically chosen.
  • Java’s uni-code to the ASCII rules is 16-bit, while C++ program is 8-bit only, So, C++ may be a less impressive programming language but saves the memory.
  • What To Avoid in C++ :

  • Don’t put “using namespace std;” into headers.
  • Avoid calling virtual functions in constructors
  • Learn about const correctness. Any method that doesn’t alter class state should be marked const, and any reference you’re not going to change should be const.
  • Don’t use new/delete.