Thread: Inserting pointer to an object in vector in a map

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    115
    Quote Originally Posted by GReaper View Post
    So, you want multiple weapons to match on the same key? You can't do that with a map, I don't think. What you need is a multimap.
    No, I want each weapon to have a unique key. But, you are right, each iteration of the loop moves the same pointer to a new weapon. But how can I insert a copy of pointers to disabled weapons?

    Also, the line in loop is ment to read

    Code:
    auto WeaponPtr = weapon;
    And I think this was the error.
    Last edited by serge; 09-22-2019 at 12:59 PM.

  2. #2
    Registered User
    Join Date
    May 2008
    Posts
    115
    One more question in this vein: Does

    Code:
    DamageLog.clear();
    kill all pointers? I am rewriting the log each game turn instead of updating it (for security). So I am clearing at the beginning of the log function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. vector of object inside object not getting populated
    By progmateur in forum C++ Programming
    Replies: 2
    Last Post: 06-15-2019, 05:36 AM
  2. Inserting New Element to a vector List
    By AC_Player in forum C++ Programming
    Replies: 1
    Last Post: 06-02-2018, 09:08 PM
  3. Inserting struct data into a vector?
    By Glauber in forum C++ Programming
    Replies: 22
    Last Post: 05-27-2008, 09:58 AM
  4. How can I define and pass a pointer to a vector object?
    By asmileguo in forum C++ Programming
    Replies: 3
    Last Post: 09-07-2006, 11:19 AM
  5. pointer to struct object in class object
    By Stevo in forum C++ Programming
    Replies: 3
    Last Post: 02-25-2004, 07:58 PM

Tags for this Thread