Thread: accessor function return type ptr to map

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    450

    accessor function return type ptr to map

    Can't seem to get this to work and can't find any examples in my book with a return type ptr.
    Code:
    map<string,Book> *get_ptrLibrary() const{return *ptrLibrary;};

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    161
    If ptrLibrary is actually a pointer, then it's just:
    Code:
    return ptrLibrary;
    If it's an object, then you have to return the address of it using the address-of operator:
    Code:
    return &ptrLibrary;

  3. #3
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    You should really study your pointers...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. Dynamic list of Objects in External File
    By TechWins in forum C++ Programming
    Replies: 3
    Last Post: 12-18-2002, 02:05 PM