Declaring an array inside a class

Hi, I was writing a code in which I use two different classes; contact and phonebook. I want to declare an array of type contact in the phonebook class, but can't figure out how to do so. Is there a simple way to do it?
1
2
3
4
class PhoneBook
{
   Contact myContact[10];
}
If Contact has two types of variables in it, string and int, can the myContact array have its first element to be a string and the second element to be an int?
if the Contact class is an aggregate class then you can do this:

1
2
3
4
5
6
7
8
9
10
11
12
13
Contact myContact[10]
{
    { "Name1",1 },
    { "Name2",2 },
    { "Name3",3 },
    { "Name4",4 },
    { "Name5",5 },
    { "Name6",6 },
    { "Name7",7 },
    { "Name8",8 },
    { "Name9",9 },
    { "Name10",10 }
};


if not then do this:

1
2
3
4
5
6
7
Contact myContact[10]
{
    Contact("Name1",1),
    Contact("Name2",3),
    Contact("Name2",3)
    /// and so on
};
Thanks a lot!
Topic archived. No new replies allowed.