Thread: Inheritance question

  1. #16
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    except you dont need a vector<vector<Tile*>> you could possibly use a vector<Tile*> but then again, you gain nothing by doign this AFAIK. I am assumign the number of terrain types is constant, and the only reason to use an array or vector is to speed up the terrain loop by replacing the switch statement with an index calculation. I havent tested the speed of indexing into a vector<> versus an array, but at best it would be the same speed so you gain nothing and lose stability, since a vector<> will tend to go out of scope without safeguards, while a dynamically allocated array will not.

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Dynamic allocations is prone to memory leaks. And if you don't need a dynamic array, you can just as well use boost::array (or std::tr1::array), which is static. Boost::array even asserts if you access an element that does not exist.

    And the vector is a replacement tool for allocating big arrays of pointer-to-pointers, and the need for new for such a thing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Noob question about templates & inheritance
    By blacknail in forum C++ Programming
    Replies: 9
    Last Post: 10-25-2008, 01:51 PM
  2. Virtual inheritance
    By 6tr6tr in forum C++ Programming
    Replies: 13
    Last Post: 05-07-2008, 11:20 AM
  3. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  4. Inheritance vs Composition
    By Panopticon in forum C++ Programming
    Replies: 11
    Last Post: 01-20-2003, 04:41 AM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM