Help with objects using struct

I want 5 objects to be created with a label and number

So it would be: A1,A2,A3,A4,A5 then other five to be B1,B2,B3,B4,B5.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  struct object{
    int value;
    char label;
  object(){
     //In this constructor, I feel like vector can be 
//used to define the value and add label but i dont know.
  }

};


int main(){
// I think constructors will be 
//helpful but I don't know how to use them.
}    
    
    


I'm a newb so if convenient add comments to your codes.
Last edited on
1
2
3
4
5
6
7
8
9
10
  struct object{
    int value;
    char label;

};


int main(){
    object o1[] = { { 0, 'A' }, { 1, 'B' }, ... }; // Note that the array can be as large as you want it
}    


Further note: Due to line 3 you can store only a single char (like 'A') not more.
Topic archived. No new replies allowed.