Learn C++ fast - Third tutorial (Functions in C++ and builing a simple calculator) by GhoUL

Опубликовано: 04 Август 2026
на канале: GhoUL's Tutorials
117
0

The main aim of this video is that you understand c++ functions and build a basic calculator.
Summary:
Functions: Functions contains code and is built to do a specefic job that you desire. Like you can build a function to perform summation or print something. You can create functions for anything.
A function(unless a constructor/destructor function) will execute if and only if it is called. In this video we don't talk about constructors/ destructors.
To execute or call a function. The code is "function name(parameters)".
Function name starts with function return type(eg: int,string) and then with function's name. If you dont want the fuction to return anything, start function with void.
Eg: void print(){ your code}
or int sum(int a, int b){your code
return x;}
The things inside the brackets are the parameters. Parameters are used to feed values to function on which it will work.
C++ reads a program line by line.
So you need to create the function before the line in which it is called.
There is an alternative solution. You can do function prototyping.
Function prototyping: Copy the functions name and paste it at the top. Now, even if you create the function at the bottom most lines. It will work fine.