Thread: zeroing out default constructor?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #15
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by JVene
    and you'll have to initialize with push_back to create sufficient entries in the vector.
    This is not true since one could just initialise the vectors to be of the desired size.

    EDIT:
    The problem of array bounds still applies here. For example, the raceInfo() member function assumes that the arrays referenced by its pointer parameters have at least three or four elements, but a mistake by the caller could then lead to array out of bounds access.

    std::tr1::array can help alleviate this problem by allowing you to have fixed size arrays that know their own size, with no or almost no overhead over using arrays directly.
    Last edited by laserlight; 05-17-2009 at 12:26 PM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. default constructor
    By rahulsk1947 in forum C++ Programming
    Replies: 1
    Last Post: 06-10-2009, 12:52 PM
  2. Creating array of objects w/o default constructor
    By QuestionC in forum C++ Programming
    Replies: 19
    Last Post: 05-02-2007, 08:03 PM
  3. template class default constructor problem
    By kocika73 in forum C++ Programming
    Replies: 3
    Last Post: 04-22-2006, 09:42 PM
  4. constructors
    By shrivk in forum C++ Programming
    Replies: 7
    Last Post: 06-24-2005, 09:35 PM
  5. Need help in classes
    By LBY in forum C++ Programming
    Replies: 11
    Last Post: 11-26-2004, 04:50 AM