How are C++ Pointers Useful?

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 4157 Views - Last Post: 28 July 2011 - 08:36 AM Rate Topic: -----

#16 jjl   User is offline

  • Engineer
  • member icon

Reputation: 1271
  • View blog
  • Posts: 4,998
  • Joined: 09-June 09

Re: How are C++ Pointers Useful?

Posted 28 July 2011 - 08:36 AM

Quote

Well... no. Its handle is just an address and while it may be stored in a local pointer, when you leave the local scope without freeing the memory it is STILL allocated even if you no long have a pointer containing its handle. But the block of memory allocated remains and can be used if you have saved the handle somehow (like storing it in some pointer).

Yes I agree, but I was refering to the scope of the handle in which the pointer belongs. The variable stays in memory; however, without access to it, I dont believe it is worth of calling it a "global variable".

I wouldn't call this variable global even though it's memory stays allocated past the handles scope.
void foo(void) {
    int *handle = new int(10);
}


This post has been edited by ImaSexy: 28 July 2011 - 08:37 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2