vectors with objects manipulation problem

I am tryin to eliminate my weakness in coding vectors. I have tried to manipulate object data inside a vector with no luck. Here is my code:
1
2
3
4
5
6
7
  vector<actor> pc;
    actor PC;
    PC.InitCharacter();
    pc.push_back(PC);
    vector::iterator pcit;
    pcit[0];
    pcit->DEVstat_check();

I want to be able to dynamically create objects of a class. That I can do. The problem is that I cannot figure out how to use the members of the class inside the vector. The objects will be dynamic.
pc[0].DEVstat_check();

Or if you want to use an iterator:
1
2
auto pcit=pc.begin();
pcit->DEVstat_check();
What's the auto keyword for?

Edit:

Oy yeah. I almost forgot. Thank you, Athar. :)
Last edited on
For Athar to see if I am getting it right.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
vector<actor> pc; //create vector called pc
    actor PC1; //create actor called PC1
    PC1.InitCharacter(); //initiate variables for PC1... I may just put this in the constructor
    pc.push_back(PC1); //adding PC1 to vector pc
    actor PC2; //ditto
    PC2.InitCharacter(); //ditto
    pc.push_back(PC2); //ditto
    actor PC3; //ditto
    PC3.InitCharacter(); //ditto
    pc.push_back(PC3); //ditto
    vector<actor>::iterator pcit; //creating an iterator of type actor called pcit
    pc[0].setstrength(1); //for testing purposes
    if(true) //does it change and stay changed in and out of a if statement
    pc[1].setstrength(2); //ditto
    while(true){ //how about a while statement
    pc[2].setstrength(3); //ditto
    break;
    }
    pc[0].DEVstat_check(); //only one way to see if the stats were changed
    pc[1].DEVstat_check(); //ditto
    pc[2].DEVstat_check(); //ditto 
Yeah, that's about how it works.
And this:
I may just put this in the constructor

is a very good idea.
It was just a side thought. I have been testing code against my knowledge and have been relearning a lot of things. I have not reorganized all of the functions and classes yet.

I have a favor to ask if you have the time...
Could you sneak a look at another question I have posited to the forum?
thanks for all your help with the vectors.
Topic archived. No new replies allowed.