🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
All Subjects
Free · 118 Topics · No Signup

C++ Notes

Core C++ — OOP, templates, STL, memory and modern syntax — written by CodingNow 2.0's mentors. Free to read, structured to actually help you learn.

C++ notes by CodingNow 2.0 cover 118 topics — from c++ home to c++ projects — each explained with short definitions, syntax and runnable code examples. They are 100% free, need no signup, and work as quick revision for college exams, C++ interviews and CodingNow 2.0's mentor-led C++ course in Pitampura, Delhi.

No notes found. Try a different search term, or browse all C++ notes.

C++ Tutorial

72 of 72 topics published
1

C++ HOME

C++ is used to create computer programs, and is one of the most used languages in game development.

2

C++ Intro

C++ is a cross-platform language that can be used to create high-performance applications.

3

C++ Get Started

At W3Schools, you can try C++ without installing anything.

4

C++ Syntax

Let's break up the following code to understand it better:

5

Statements

A computer program is a list of "instructions" to be "executed" by a computer.

6

C++ Output

The cout object, together with the << operator, is used to output values and print text.

7

Print Numbers

You can also use cout() to print numbers.

8

New Lines

To insert a new line in your output, you can use the \n character:

9

C++ Comments

Comments can be used to explain C++ code, and to make it more readable. It can also be used to prevent execution when testing alternative code. Comments can be

10

C++ Variables

Variables are containers for storing data values.

11

Multiple Variables

To declare more than one variable of the same type, use a comma-separated list:

12

Identifiers

All C++ variables must be identified with unique names.

13

Constants

When you do not want others (or yourself) to change existing variable values, use the const keyword (this will declare the variable as "constant", which means

14

Real-Life Examples

Often in our examples, we simplify variable names to match their data type (myInt or myNum for int types, myChar for char types, and so on). This is done to

15

C++ User Input

You have already learned that cout is used to output (print) values. Now we will use cin to get user input.

16

C++ Data Types

As explained in the Variables chapter, a variable in C++ must be a specified data type:

17

Numbers

Use int when you need to store a whole number without decimals, like 35 or 1000, and float or double when you need a floating point number (with decimals)

18

Booleans

A boolean data type is declared with the bool keyword and can only take the values true or false .

19

Characters

The char data type is used to store a single character. The character must be surrounded by single quotes, like 'A' or 'c':

20

Strings

The string type is used to store a sequence of characters (text). This is not a built-in type, but it behaves like one in its most basic usage. String values

21

The auto Keyword

The auto keyword automatically detects the type of a variable based on the value you assign to it.

22

Real-Life Example

Here's a real-life example of using different data types, to calculate and output the total cost of a number of items:

23

C++ Operators

Operators are used to perform operations on variables and values.

24

Arithmetic

Arithmetic operators are used to perform common mathematical operations.

25

Assignment

Assignment operators are used to assign values to variables.

26

Comparison

Comparison operators are used to compare two values (or variables). This is important in programming, because it helps us to find answers and make decisions.

27

Logical

As with comparison operators, you can also test for true ( 1 ) or false ( 0 ) values with logical operators.

28

Precedence

When a calculation contains more than one operator, C++ follows order of operations rules to decide which part to calculate first.

29

C++ Strings

Strings are used for storing text/characters.

30

Concatenation

The + operator can be used between strings to add them together to make a new string. This is called concatenation:

31

Numbers and Strings

Warning: WARNING! C++ uses the + operator for both addition and concatenation. Numbers are added. Strings are concatenated.

32

String Length

To get the length of a string, use the length() function:

33

Access Strings

You can access the characters in a string by referring to its index number inside square brackets .

34

Special Characters

Because strings must be written within quotes, C++ will misunderstand this string, and generate an error:

35

User Input Strings

It is possible to use the extraction operator on cin to store a string entered by a user:

36

Omitting Namespace

You might see some C++ programs that run without the standard namespace library. The using namespace std line can be omitted and replaced with the std keywo

37

C-Style Strings

C-style strings are created with the char type instead of string .

38

C++ Math

C++ has many functions that allows you to perform mathematical tasks on numbers.

39

C++ Booleans

Very often, in programming, you will need a data type that can only have one of two values, like:

40

Boolean Expressions

A Boolean expression is a piece of code that compares values or variables and returns a boolean value: 1 (true) or 0 (false).

41

Real-Life Example

Let's use booleans in a real-life example where we want to find out if a person is old enough to vote.

42

C++ If...Else

You already know that C++ supports familiar comparison conditions from mathematics, such as:

43

else

Use the else statement to specify a block of code to be executed if the condition is false .

44

else if

Use the else if statement to specify a new condition to test if the first condition is false .

45

Short hand if..else

There is also a short-hand if...else, known as the ternary operator because it uses three operands.

46

Nested if

You can also place an if statement inside another if . This is called a nested if statement.

47

Logical Operators

You can combine or reverse conditions using logical operators. These work together with if , else , and else if to build more complex decisions.

48

Real-Life Examples

This example shows how you can use if..else to "open a door" if the user enters the correct code:

49

C++ Switch

Use the switch statement to select one of many code blocks to be executed.

50

C++ While Loop

Loops can execute a block of code as long as a specified condition is reached.

51

Do/While Loop

The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true. Then it will repeat

52

Real-Life Examples

To demonstrate a practical example of the while loop, we have created a simple "countdown" program:

53

C++ For Loop

When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop:

54

Nested Loops

It is also possible to place a loop inside another loop. This is called a nested loop.

55

The foreach Loop

There is also a "for-each loop" (also known as ranged-based for loop), which is used to loop through elements in an array (or other data structures):

56

Real-Life Examples

To demonstrate a practical example of the for loop, let's create a program that counts to 100 by tens:

57

C++ Break/Continue

You have already seen the break statement used in an earlier chapter of this tutorial. It was used to "jump out" of a switch statement.

58

C++ Arrays

Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.

59

Arrays and Loops

You can loop through the array elements with the for loop.

60

Omit Array Size

In C++, you don't have to specify the size of the array. The compiler is smart enough to determine the size of the array based on the number of inserted values:

61

Get Array Size

To get the size of an array, you can use the sizeof() operator:

62

Real-Life Example

To demonstrate a practical example of using arrays, let's create a program that calculates the average of different ages:

63

Multidimensional Arrays

A multi-dimensional array is an array of arrays.

64

C++ Structures

Structures (also called structs) are a way to group several related variables into one place.

65

C++ Enums

An enum is a special type that represents a group of constants (unchangeable values).

66

C++ References

A reference variable is an alias for an existing variable. It is created using the & operator:

67

Memory Address

In the example from the previous page, the & operator was used to create a reference variable. But it can also be used to get the memory address of a variable

68

C++ Pointers

You learned from the previous chapter, that we can get the memory address of a variable by using the & operator:

69

Dereferencing

In the example from the previous page, we used the pointer variable to get the memory address of a variable (used together with the & reference operator). How

70

Modify Pointers

You can also change the pointer's value. But note that this will also change the value of the original variable:

71

C++ Memory Mgmt

Memory management is the process of controlling how much memory your program uses - and how it is used. This includes creating, using, and releasing memory when

72

new and delete

The new keyword lets you manage memory yourself.

C++ Functions

13 of 13 topics published
73

C++ Functions

A function is a block of code which only runs when it is called.

74

C++ Function Parameters

Information can be passed to functions as a parameter. Parameters act as variables inside the function.

75

Default Parameter

You can also use a default parameter value, by using the equals sign ( = ).

76

Multiple Parameters

Inside the function, you can add as many parameters as you want:

77

Return Values

The void keyword, used in the previous examples, indicates that the function should not return a value. If you want the function to return a value, you can us

78

Pass By Reference

In the examples from the previous page, we used normal variables when we passed parameters to a function.

79

Pass Arrays

Note: Example Explained The function ( myFunction ) takes an array as its parameter ( int myNumbers 5 ), and loops through the array elements with the f

80

Pass Structures

You can also pass a structure to a function.

81

Real-Life Example

To demonstrate a practical example of using functions, let's create a program that converts a value from fahrenheit to celsius:

82

C++ Function Overloading

Function overloading allows multiple functions to have the same name, as long as their parameters are different in type or number:

83

C++ Scope

Now that you understand how functions work, it is important to learn how variables act inside and outside of functions.

84

C++ Recursion

Recursion is the technique of making a function call itself.

85

C++ Lambda

A lambda function is a small, anonymous function you can write directly in your code. It's useful when you need a quick function without naming it or declaring

C++ Classes

17 of 17 topics published
86

C++ OOP

OOP stands for Object-Oriented Programming.

87

C++ Classes/Objects

C++ is an object-oriented programming language.

88

C++ Class Methods

Methods are functions that belongs to the class.

89

C++ Constructors

A constructor is a special method that is automatically called when an object of a class is created.

90

Constructor Overloading

In C++, you can have more than one constructor in the same class. This is called constructor overloading.

91

C++ Access Specifiers

Access specifiers control how the members (attributes and methods) of a class can be accessed.

92

C++ Encapsulation

The meaning of Encapsulation, is to make sure that "sensitive" data is hidden from users.

93

C++ Friend Functions

Normally, private members of a class can only be accessed using public methods like getters and setters. But in some cases, you can use a special function cal

94

C++ Inheritance

Inheritance allows one class to reuse attributes and methods from another class. It helps you write cleaner, more efficient code by avoiding duplication.

95

Multilevel Inheritance

A class can also be derived from one class, which is already derived from another class.

96

Multiple Inheritance

A class can also be derived from more than one base class, using a comma-separated list:

97

Access Specifiers

You learned from the Access Specifiers chapter that there are three specifiers available in C++.

98

C++ Polymorphism

Polymorphism means "many forms", and it occurs when we have many classes that are related to each other by inheritance.

99

Virtual Functions

A virtual function is a member function in the base class that can be overridden in derived classes.

100

C++ Templates

Templates let you write a function or class that works with different data types.

101

C++ Files

The fstream library allows us to work with files.

102

C++ Date

The <ctime library allows us to work with dates and times.

Ready to go from notes to a real career?

Join CodingNow 2.0's C++ course — live mentorship, hands-on projects, and 100% placement support in Delhi NCR.

Enroll Now — Free Demo Available

C++ Notes – FAQs

What students search before reading C++ notes.

Yes — all 118 C++ topics on CodingNow 2.0 are completely free with no signup or paywall. Read them in the browser on mobile or desktop.
This hub covers 118 structured C++ topics — from absolute basics to advanced, interview-ready concepts — each with short explanations and working code examples.
The notes are written to be self-study friendly, but for job-ready skills, projects and placement support, CodingNow 2.0's mentor-led C++ course in Delhi (online + classroom) is the fastest path.
Yes. Each topic is concise and example-driven — ideal for last-minute revision before college exams, campus placements and C++ job interviews in India.
Working AI/ML engineers and full-stack developers from CodingNow 2.0 – Gurukul of AI, Pitampura Delhi, aligned with our 2026 course curriculum.
WhatsApp
Call NowEnroll Now