Accessing vector pointers

This is a discussion on Accessing vector pointers within the C++ Programming forums, part of the General Programming Boards category; Hi..... I have a problem with my code. Let's say I have a pointer pointing to a vector of Customer ...

  1. #1
    blue8173
    Guest

    Accessing vector pointers

    Hi.....

    I have a problem with my code.

    Let's say I have a pointer pointing to a vector of Customer pointers:

    Code:
    vector<Customer*> *vCustomers;
    how would I be about to access the public methods in the Customer class?

    for example, if I wanted to access a public method "void shop();"?

    I tried:

    Code:
    vCustomers[0]->shop();
    but this is giving me an error:
    no matching function for call to `std::vector<Customer*,
    std::allocator<Customer*> >::shop()'


    Can anyone help me?
    Thanks a lot!

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Code:
    (*vCustomers)[0]->shop();
    Are you sure you need a pointer to a vector and not just a vector?
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    blue8173
    Guest

    Smile

    Thanks a lot......

    yeah, the Customer vector is actually in another class, so it need a pointer to it.......


    Thanks again!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. vector : accessing values
    By rahulsk1947 in forum C++ Programming
    Replies: 1
    Last Post: 06-01-2009, 09:26 PM
  2. Accessing USB devices
    By deviousdexter in forum C# Programming
    Replies: 1
    Last Post: 01-24-2009, 08:48 PM
  3. Problems accessing logged on user via System.Security
    By conor20_ie in forum C# Programming
    Replies: 5
    Last Post: 11-16-2007, 06:52 AM
  4. problems accessing an external file
    By tony24tone in forum C Programming
    Replies: 2
    Last Post: 05-16-2004, 06:51 PM
  5. accessing bytes of a file
    By neandrake in forum C++ Programming
    Replies: 2
    Last Post: 03-05-2002, 07:41 PM

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