Vectors

This is a discussion on Vectors within the C++ Programming forums, part of the General Programming Boards category; Note that your contactDelete function does not return a vector<contact> but a vector<contact>*. *edit* That method of deleting a contact ...

  1. #16
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Note that your contactDelete function does not return a vector<contact> but a vector<contact>*.

    *edit*
    That method of deleting a contact is rather dangerous too as you are returning a pointer to memory which has gone out of scope. It would be better just to return void and take the vector argument as a reference and remove the contact directly from it.

    Also, in loops and such, it is a better habit to get into to use iterator!=iterator instead of iterator<=iterator as not all iterators are random access.

    Cheers
    Last edited by Zach L.; 11-28-2004 at 03:51 PM.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Vectors
    By naseerhaider in forum C++ Programming
    Replies: 11
    Last Post: 05-09-2008, 08:21 AM
  2. How can i made vectors measuring program in DevC++
    By flame82 in forum C Programming
    Replies: 1
    Last Post: 05-07-2008, 02:05 PM
  3. How properly get data out of vectors of templates?
    By 6tr6tr in forum C++ Programming
    Replies: 4
    Last Post: 04-15-2008, 10:35 AM
  4. How to use Vector's in C++ !?!
    By IndioDoido in forum C++ Programming
    Replies: 3
    Last Post: 10-14-2007, 11:13 AM
  5. Points, vectors, matrices
    By subnet_rx in forum Game Programming
    Replies: 17
    Last Post: 01-11-2002, 01:29 PM

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