I'm begginer c++ programmer . Array of pointers?!

I'm beginner C + + programmer. I have to implement a code that asks you to simulate the election of the president (in a simplified way). The text says to predict 3 classes: 1) Candidate 2) Elector 3) Seat. Seat In Electors can vote up to 10 the list of which is unknown. Each elector expresses the preference of a candidate by inserting a string and stores the data entered anonymously. I do not understand how I should handle this part. I created a class where Elector header declare the default constructor without parameters, I get the output through the overload of operator Flow "<<", full name of each elector, while using the set and get methods to store the id of each elector (I assumed that each voter will have a different id) and use set and get well to store the string that indicates the preference of a candidate. How do I store the value of each string you insert in the class Elector in order to increase the array of objects Candidate? . I think we need to create an array of pointers to an object Candidate .. ? But how do you .. Help!
[ I'm Italian, sorry for my english ]
You create an array of pointers the same way as you create an array of any other type.

For example, an array of 10 integers would be:

int myIntArray[10];

and an array of 10 pointers to integers would be:

int* myIntPtrArray[10];

Although I'd advise you to learn about STL vectors, instead of C-style arrays. They're much safer and easier to use, once you've learnt them.
Last edited on
ok , i can post the code ? for safety ..
Sure, post it!
Topic archived. No new replies allowed.