user defined datatype/vector elements

Write your question here.

I have a user defined data type it has 5 strings and 6 ints that make up the object. this object is one in a vector. how do you change one piece of that element?? not a piece of the vector but of one element?
you mean you have vector<MyClass> x? If so, you can use:
x[0].string1 = "xe"; //Changes member "string1" in first element of vector.
Last edited on
You tried something like this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
structCDATA
{
     string szName;
     int iAge;
}cTemp;

vector<CDATA> vecUserData;

cTemp.szName="Aceix";
cTemp.iAge=101;

vecUserData.push_back();

cout<<vecUserData[0].szName;
vecUserData[0].iAge=102;

cout<<"My birth time has just passed and 1 yr has been added to my age.";


HTH,
Aceix.
Topic archived. No new replies allowed.