Thread: problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    84
    Quote Originally Posted by matsp View Post
    Do you mean like this?
    Code:
    class x
    {
        std::vector<int> v;
    ...
    }
    If not, please explain again what you want to do.

    --
    Mats
    no, like something i tried in the code

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Seeing as I don't fully understand WHAT you are trying to achieve, that makes it very hard to explain how you SHOULD do that.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    84
    Quote Originally Posted by matsp View Post
    Seeing as I don't fully understand WHAT you are trying to achieve, that makes it very hard to explain how you SHOULD do that.

    --
    Mats
    Code:
    }classesDB[MAX_CLASSES], *charClass;
    
    void LoadClasses()
    {
    	classesDB[0].classInfo(3, "Warrior", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5);
    }
    I'm trying to do this but instead of using arrays I want to use vectors.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So, you either size/resize your vector as need be, or you create a temporary object and add it using push_back().

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    84
    Quote Originally Posted by matsp View Post
    So, you either size/resize your vector as need be, or you create a temporary object and add it using push_back().

    --
    Mats
    Well I know that. But nevermind, I thought there supposed to be a special way too initialize class vector objects.

    Code:
    void LoadRaces()
    {
    	vector<Races>racesDB;
    
        racesDB.push_back(Races(1, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5));
    
    	racesDB.push_back(Races(2, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5));
    
        racesDB.push_back(Races(3, ANCIENA_S, "a", "a", "a", 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5));
    }
    Can I somehow declare the raceDB vector right after the class?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM