accessor function return type ptr to map

This is a discussion on accessor function return type ptr to map within the C++ Programming forums, part of the General Programming Boards category; Can't seem to get this to work and can't find any examples in my book with a return type ptr. ...

  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
    lyx
    lyx is offline
    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, 01:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21