Dremendo Tag Line

Learn to Code in C++: The Ultimate Tutorial

C++ Basic Concepts
c++ programming tutorial

In this lesson, you'll be taken on a step-by-step journey through C++ programming. We'll cover everything from the language's fascinating history to its cutting-edge applications and key features. You'll also gain insight into the similarities and differences between C and C++. Get ready to expand your programming knowledge and sharpen your skills!

C++ Introduction

C++ is a general-purpose and object-oriented programming language.

  • General-Purpose - C++ is a very flexible computer language. The areas of the application of C++ is very wide. One can create various types of software using this language.
  • Object-Oriented - C++ is a model of programming which aims to work with the real-world entities in programming. Such as inheritance, data hiding, polymorphism etc. The main aim of OOP (Object Oriented Programming) is to bind a specific portion of data and functions together so that no other part, of rest of the code, can access them.

Who developed C++ programming language?

A Danish computer scientist named Bjarne Stroustrup developed the C++ language. Since 1979 he was working at the Computer Science Research Centre of Bell Labs, New Jersey, USA on an extension of the C language. He wanted to create an efficient and flexible language which is similar to C but provided high-level features for program organization.

Applications of C++

C++ language is used in the following areas given below:

  • To Design Operating System
  • To Design Database
  • To Develop Engineering Application
  • To Develop Medical Application
  • In Embedded Systems
  • To Built Enterprise Software
  • In Development of New Languages
  • To Develop Web Browsers
  • To Develop Games
  • To Design Compilers
  • To Develop Desktop Applications

Key features of C++

The main key features of C++ language are listed as follows:

  • Encapsulation - Encapsulation is the process where data and functions combined into a single unit called class. After using this method, the data can be accessed only through the functions of the class. It cannot be directly accessed even by the programmer himself and this led to the notion of data hiding in programming.
  • Abstraction - It is one of the most vital features of the object-oriented C++ programming language. The data abstraction is about giving a clear division between the properties of datatype and the associated implementation details.
  • Polymorphism - The ability to use an operator or function in many different ways is called the Polymorphism. The word Poly refers to the many uses of these operators and functions can have. A real-life example of polymorphism can be a man who is at the same time a father, a husband and a businessman. Thus a single function used in many different ways can be called polymorphism.
  • Inheritance - Inheritance is the process of creating new class which is called derived class, from the already existing class which is called base class. The derived class will have all the features of the base class from which it has derived. Now the programmer can add new features to the newly created derived class, which will not affect the base class.
  • Library Support - A large collection of C++ libraries of already written modules and functions is available in the market, making the coding easier and quicker in every aspect.
  • Speed - If quick responsiveness is a critical metric for the desired application, then C++ is preferred before other languages. The speed of compilation and execution in C++ is faster than other programming languages.
  • Compiler-Based - Unlike Java and Python that are interpreter-based, C++ is a compiler based language and hence it a relatively much faster than Python and Java.
  • DMA (Dynamic Memory Allocation) - Since C++ supports the use of pointers, it allows us to allocate memory dynamically. We may even use constructors and destructors while working with classes and objects in C++.
  • Portable Source Code - C++ cannot run without a compiler. It needs separate compilers for separate Operating System. If you have a compiler for Windows platform C++ will only run properly on Windows. And the same goes for other platforms.

Similarities between C and C++

  • Both the languages have a similar syntax.
  • Code structure of both the languages are same.
  • The process of compilation of both languages is same.
  • They share the same basic syntax. Almost all of operators and keywords in both the languages do the same thing.
  • Though C++ has a slightly extended structure than C, yet the basic grammar is the same.
  • The memory model of both the language is very close to the hardware.
  • Stack, heap, file-scope and static variables, these are present in both the languages.

Difference between C and C++

This table below is showing the difference between C and C++:

C C++
It was developed between 1969 and 1973 by Dennis Ritchie, an American computer scientist at AT&T Bell Labs. C++ was developed by a Danish computer scientist Bjarne Stroustrup in 1979.
C is not an object-oriented programming language, and thus it does not support polymorphism, encapsulation, and inheritance. C++ is an object-oriented programming language so polymorphism, encapsulation, and inheritance works fine in this language.
C contains 32 keywords. C++ contains 63 keywords.
For the development of code, C supports procedural programming. C++ is known as hybrid language because C++ supports both procedural and object oriented programming paradigms.
Data and functions work separately in C because it is a procedural programming language. Data and functions work together because they are encapsulated in a single unit called class.
Data or information hiding is not a feature of C. In C++ data is hidden by the Encapsulation using a class.
C is a function-oriented language. C++ is an object driven language because it is object-oriented programming.
You can not overload function and operator in C. You can overload function and operator in C++.
Functions can not be set inside a structure. Functions can be applied inside a structure.
Namespace features are not there in the C. To avoid name collisions the namespace is used in C++.
The name of the header file in C is stdio.h. The name of the header file used by C++ is iostream.
C does not support Reference variables. C++ supports reference variables.
Virtual and friend functions are not supported. Virtual and friend functions are supported.
Does not support inheritance. Supports inheritance.
Instead of focusing on data, C focuses on the process of programming. Instead of focusing on the process, C++ focuses on data of programming.
C provides malloc() and calloc() functions for dynamic memory allocation, and free() for memory de-allocation. C++ provides a new operator for memory allocation and delete operator for memory de-allocation.
Direct support for exception handling is not supported by C. Exception handling is supported by C++.
scanf() and printf() functions are used for input/output in C. cin and cout are used for input/output in C++.

Test Your Knowledge

Attempt the multiple choice quiz to check if the lesson is adequately clear to you.

Test Your Knowledge