Inheritance question

This is a discussion on Inheritance question within the C++ Programming forums, part of the General Programming Boards category; except you dont need a vector<vector<Tile*>> you could possibly use a vector<Tile*> but then again, you gain nothing by doign ...

  1. #16
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    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.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  2. #17
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,180
    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.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

Page 2 of 2 FirstFirst 12
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, 08:22 PM
  4. Inheritance vs Composition
    By Panopticon in forum C++ Programming
    Replies: 11
    Last Post: 01-20-2003, 03:41 AM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 02:57 PM

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