I have something like this:
int* a = NULL;
int* b = *a;
b = new int(5);
std::cout << *a;
std::cout << *b;
I would like to instantiate a
from b
so a
has the value 5. Is this possible?
EDIT:
actual code is something like this -
int* a = null; //Global variable
int* b = null; //Global variable
int* returnInt(int position)
{
switch(position)
{
case 0:
return a;
case 1:
return b;
}
}
some other function -
int* c = returnInt(0); // Get Global a
if (c == null)
c = new int(5);
i want to instantiate the global variables this way if possible.