Passing By Value

This lesson introduces the way by which we pass values to a function.

We'll cover the following

Functions are building blocks of C++.

A function is a named part of a program that can be invoked from other parts of the program as often needed.

Arguments Passed By Value

In C++, by default variables, are passed by value to functions. This means that a copy of the data is made and passed to the function. This is in contrast to passing by reference or by pointer, in which case the address of the object itself is passed to the function.

However, let’s first look at what passing arguments by value means:

Consider the following program that accepts a number and prints its cube:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy