Abdul Bari

C++ is a general-purpose programming language with object-oriented programming (OOP) principles, memory management, and an extensive library of classes. C++ is considered a type-safe language due to the OOP principles allowing developers to hide and protect variables. It is also a high-performance language.

History of C++

C++ is a programming language based on the C language developed by Dennis Ritchie in the early 1970s at Bell Labs. C++ was developed by Bjarne Stroustrup at Bell Labs in the early 1980s. C++ was designed to be C with classes. Today, the modern C++ Standard Library has a rich collection of classes and functions. 

Learn C++ Programming -Beginner to Advance- Deep Dive in C++

Last Updated October 2020

  • 279 lectures
  • All Levels
4.6 (8,034)

Classroom and Hands-on sessions- Features of C++ 11 , Exception Handling and STL – for Both Academics and Industry | By Abdul Bari

Explore Course

C++ is standardized by the International Organization for Standards (ISO). Since 2012, the language has been on a three-year publication schedule. The next two planned releases are C++20 and C++23.

C++ Usage 

C++ can be used with different programming styles, including procedural, object-oriented, and functional.  The C++ Standard Library has an extensive set of classes and functions related to graphical user interface (GUI) development. The library support tools, language flexibility, and performance characteristics lend the language to a wide range of applications, including games, server components for cloud and distributed systems, GUI applications, banking software, browsers, and operating systems.

.Net, Java and most JavaScript interpreters are also written in C and C++.

Companies that use C++

Many companies use C++ for mission-critical applications and components.  

For example:

Features of C++

Some of the most important features of C++ are related to data security, data encapsulation, and data hiding. Defining objects with data and functional classes provides a type-safe environment.

C++ also offers the following features:

Some of these features are advanced and provide developers with a deep level of control and access to the OS and hardware.

Differences between C and C++

FeatureCC++
Programming ApproachProcedural Programming Allows for procedural, object-oriented, and functional approaches
OOPNot SupportedFully supports OOP
Data TypesContains Structures for user-defined datatypes.In addition to user-defined data types, the C++ Standard Library has standardized data types.
Data SecurityC does not support encapsulation so data behave as a free entity and can be manipulated by outside code.C++ encapsulation hides the data to ensure that data structures and operators are used as intended by object classes and functions.
InteroperabilityCannot run C++ programs.Can include and execute most C programs.
Keywords32 keywords.60 keywords.
Exception and Error HandlingException handling is not supported.Exception handling is supported.
Program StructureFocuses on procedures and methodsFocuses on objects with functions, classes, and data
Optimization and PerformanceOptimizes code using macro functions.Uses inline functions to optimize code.

C++ Program Structure

// Basic Hello World
#include <iostream>

int main()
{
  std::cout << "Hello World!";
}

This is a basic Hello World program.  Let’s look at each line to understand the program.

Comment – // Basic Hello World

Text that is prefaced with two slashes is ignored by the compiler and allows the developer to add notes to indicate the intent of the code

Preprocessor Directive – #include <iostream>

Lines beginning with a hash sign (#) are directives.  In this case, the directive is to include the iostream C++ Standard Library functions.

Main Function – int main()

A function includes three components. The type of function – in this case, int for integer. The name of the function – main.  Main is a special function name because it is the function the program will run when it is started. The last component is a set of optional parameters.

Note that there are open and closing brackets {}. These define the start and end of the function and all lines of code within these brackets are executed with that function.

Function Statement – std::cout << “Hello World!”;

This is the line of code executed by the main function. It uses “std::cout” which is part of the iostream library included at the beginning. ‘std::cout’ is the standard character output device, and this is usually the computer screen. The insertion operator (<<) indicates we want to insert something into the standard character output device. The text in quotes – “Hello World!” – is what will be inserted.

This function statement prints “Hello World” to the computer screen.

Notice the line ends with a semicolon (;). The semicolon marks the end of a statement.

This same program could be written with a function to write the text to the screen. In this case, the main function calls the print_hello function to output the text to the screen.

// Basic Hello World with functions
#include <iostream>

int main()
{
  print_hello();
}
int print_hello()
{
  std::cout << "Hello World!";
}

Conclusion

C++ is a vast but easy to understand programming language, with a wide range of different implementations. And the best way to learn C++ is by taking a course like this one on Udemy.

Page Last Updated: December 2020

Top courses in C++

Getting Started with C++
Andrew Mehri
4.6 (17)
Beginning C++ Programming - From Beginner to Beyond
Tim Buchalka's Learn Programming Academy, Dr. Frank Mitropoulos
4.6 (33,396)
Mastering 4 critical SKILLS using C++ 17
Dr. Mostafa Saad Ibrahim
4.8 (550)
Highest Rated
Unreal Engine C++ Developer: Learn C++ and Make Video Games
Ben Tristem, Sam Pattuzzi, GameDev.tv Team, Rob Brooks
4.6 (48,847)
Bestseller
Design Patterns in Modern C++
Dmitri Nesteruk
4.4 (3,166)
Learn C++ for Game Development
Stephen Ulibarri
4.5 (1,464)
The Complete C++ Developer Course
Codestars by Rob Percival, John P. Baugh
4.6 (258)
Highest Rated
Unreal Multiplayer Master: Video Game Dev In C++
Ben Tristem, Sam Pattuzzi, GameDev.tv Team
4.6 (1,560)
Functional Programming using C++
Tobias Hermann
4.4 (287)

More C++ Courses

C++ students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy for Business.

Request a demo