array class object question

This is a discussion on array class object question within the C++ Programming forums, part of the General Programming Boards category; Code: #define MAX_M_SKILLS 6 #define MAX_SM_SKILLS 3 #define MAX_S_SKILLS 20 #define MAX_SKILLS 10 #define MAX_L_SKILLS 30 class PSkills {public:PSkills(){};}DBskills[MAX_M_SKILLS][MAX_SM_SKILLS][MAX_S_SKILLS][MAX_SKILLS][MAX_L_SKILLS]; i ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    84

    array class object question

    Code:
    #define MAX_M_SKILLS 6
    #define MAX_SM_SKILLS 3
    #define MAX_S_SKILLS 20
    #define MAX_SKILLS 10
    #define MAX_L_SKILLS 30
    
    class PSkills {public:PSkills(){};}DBskills[MAX_M_SKILLS][MAX_SM_SKILLS][MAX_S_SKILLS][MAX_SKILLS][MAX_L_SKILLS];
    i want to separate the skills into groups, the main groups(6) that later divided into sub groups(3) which divided into (20) different type skills which each one of then divided into (10) level skill who has (30) levels to each one of them
    so anyways, to use that many arrays is ok for that purpose?

    BTW: i checked and the arrays sum up over 100K
    Last edited by ExDHaos; 05-16-2009 at 08:58 AM.

  2. #2
    Registered User
    Join Date
    May 2007
    Posts
    147
    108,000 entries times what size?

    You probably need some other kind of container - it is doubtful you need every one of the 108,000 entries for every 'owner' on every occasion.

    Dynamic containers for each category make more sense, or a container of generic skills which are polymorphic objects might work well.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    84
    Quote Originally Posted by JVene View Post
    108,000 entries times what size?

    You probably need some other kind of container - it is doubtful you need every one of the 108,000 entries for every 'owner' on every occasion.

    Dynamic containers for each category make more sense, or a container of generic skills which are polymorphic objects might work well.
    well i always can use just 1D array to specify the exact numbers of skills i need, but i think the previous way will be much easier to use with code later, and i don't know any other containers.

  4. #4
    Registered User
    Join Date
    May 2007
    Posts
    147
    and i don't know any other containers.
    It seems now is the time to learn them.

    It looks to me that what you actually have are single dimension arrays, just 5 of them representing 5 categories. Using a struct or class, you can dynamically allocate these arrays to the size required.

    You may also investigate vector - a dynamically extensible array (not a great description).

    You might also consider a map or a list.

    There is no doubt you will need to consider other means. The implication of that volume of entries, unless you utilize all or most of them in each occasion, is of such waste as to be - well - a bad idea.

    Look for a tutorial on the STL - it might take you no more than a few hours to grasp vector, perhaps as much to understand list, but the time you're going to spend dealing with the approach you're considering will take longer because of the problems you'll encounter which are not yet in your focus. Still, it will be a learning experience for you as to exactly why it's a bad idea, and many of us found our own path by pursuing clearly ridiculous ideas directly into a wall.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  4. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 09:12 PM
  5. Replies: 4
    Last Post: 09-12-2001, 02:05 PM

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