
-----------------------------------
Geminias
Sun Nov 13, 2005 9:01 pm

scope and freestore
-----------------------------------
if i make a function and i create a variable on the freestore and a pointer to point to its location, how do i get access to that variables value once the function returns.  i'm guess i have to make the pointer public somehow?  or how would i do this besides put it into a class and declare it public?

-----------------------------------
wtd
Mon Nov 14, 2005 12:18 am


-----------------------------------
Have the function return the pointer.

int *foo()
{
   return new int(42);
}

int main()
{
   int *bar = foo();
}

-----------------------------------
Geminias
Mon Nov 14, 2005 3:06 pm


-----------------------------------
good, the only thing is i'd hate to have to make a function for each pointer i'd like to return, what's the format for returning multiple items?  or can you return multiple items?  lol

eg.  return 0;  //0 is one item.
      return 0 