Here is another example of how arrays work:
Code:
string Names[] = {"tom", "dick", "harry"}; //initializer list
cout<<Names[0]<<endl<<endl;; //tom
Names[2] = "alice";
for(int i=0; i<3; i++)
{
cout<<Names[i]<<endl;
}
Names[1] = " ";
cout<<Names[1]<<endl; //<a space is displayed>
1)You can also make that array value nothing--not even a space--by doing this:
Names[1] = "";
2)The initializer list:
{"tom", "dick", "harry"}
gets its name from the fact that you can only use it to 'initialize' an array. Initializing an array means you assign it some values as at the same time that you declare the array. You can't use an initializer list after you declare an array. For instance, this doesn't work:
Code:
string Names[3];
Names = {"tom", "dick", "harry"};