I was just playing with the functions and parameters.
#include <iostream>
using namespace std;
int function(char *str,int b);
int main()
{
char *str = new char[10];
memset(str,0,10);
int a = 10;
int b = 10;
function(str,b);
function(str,a);
}
//FUnction Definition
int function(char *str,int b)
{
cout << &str << "\t" << &b << "endl"
return 0;
}
I am compiling this code in VS2010 C++ ,,
When we pass something by value , a new value is created copying the contents from the variable which is passed. So definitely b
at the function body will be having different address.
What i am seeing is that the function parameters remains at the same address location in multiple calls.
What i am guessing is that parameters of the Functions are each mapped with memory locations, which wil contain the variables called on Function
I just want to know is this so or there is something else.