P
prasoonthegreat
Look at at following two functions min and min2
void min(int a[],int n)
{
static int *x=new int[n];
if(n==0)
{delete[] x;return;}
else
cout<<x<<" "<<n<<endl;
min(a,n-1);
}
void min2(int a[],int n)
{
static int *x;
x=new int[n];
if(n==0)
{delete[] x;return;}
else
cout<<x<<" "<<n<<endl;
min2(a,n-1);
}
what are difference between the static pointers in the two cases....
why do i get the same value of 'x' in the function min even though
control reaches the statement static int *x = new int[n], each time
the function is being called....
I get different values of 'x' in min2 even though the pointer is
static
(what is the significance of being static then)
tell me the difference between the following two
1) static int *p=new int[n];
2) static int *p;
p=new int[n];
I am waiting for responses.......
void min(int a[],int n)
{
static int *x=new int[n];
if(n==0)
{delete[] x;return;}
else
cout<<x<<" "<<n<<endl;
min(a,n-1);
}
void min2(int a[],int n)
{
static int *x;
x=new int[n];
if(n==0)
{delete[] x;return;}
else
cout<<x<<" "<<n<<endl;
min2(a,n-1);
}
what are difference between the static pointers in the two cases....
why do i get the same value of 'x' in the function min even though
control reaches the statement static int *x = new int[n], each time
the function is being called....
I get different values of 'x' in min2 even though the pointer is
static
(what is the significance of being static then)
tell me the difference between the following two
1) static int *p=new int[n];
2) static int *p;
p=new int[n];
I am waiting for responses.......