I've been working with functions in C++ and I dont realy know what really is going on behind them( how the wheels spin :) ). What exactly i wanna know is:
- how the parameters of a function get the values? ex:
#include<iostream>
int function(int x)
{
x += 10;
return x;
}
int main()
{
int y;
std::cin >> y;
std::cout<< function(y);
}
In reality the function parameter x will get the value y like this: x=y ?
- Based on the first question, will pass by referenece be done like this &x=y? y will be converted from int to int& ???
#include<iostream>
void function(int& x)
{
x += 10;
}
int main()
{
int y;
std::cin >> y;
function(y);
cout<<y;
}
- When we call a function how much memory will be allocated for it?how much will it consume? based on what?
I need to know everything that happens when a function is called , and how the function really work
Sorry for my bad english , I'm Romanian. Thank you!