line 11: when declaring the array you have to tell it how many items the array will contain. For example, if you want the array to contain not more than 10 names then declare it like this:
string names[10];
Declaring dynamic arrays is also possible, but apparently your class is not yet at that level, so I'll just ignore that possiblility for now.
lines 12 thru 15: not needed in function main(). The instructions you posted say nothing about doing that. You do need to add a loop in function print() to display each of the names.
Suggestion: don't attempt to do all the instructions at one time. Instead, code and test them one instruction at a time so that you don't get so confused.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>I'm really getting lost, when making the loop to have the user put in the 10 names, you would do something like
for (int i=0; i<11; i++)
Not quite. Use your fingers to count starting at, and including, zero and going through, and including 10. How many numbers did you count?
How many names do you want to store? What could the syntax be to get that number of names?
>>but what would be the cin;
If you declare arr like this:
string arr[10];
Then arr can hold up to 10 strings. Each string in arr is accessable by using the array name followed by the [] operator with an index inside the []s. The indexes indicate how many strings from the first string do you need to go to find the desired string. So if the index is zero, you want the first string. If the index is 1 you want one string beyond the first one, or the second string in the array. If the index is 5 then you wan the fifth string from the first, or the sixth string in the array.
Each string in arr is therefore known as
arr[x]
where x is the index.
You can display arr[x] using cout and you can assign a value to arr[x] using any valid techique; such as cin >>, the assignment operator, etc. In other words, arr[x] is a string, as long as x is a valid index. Valid indexes will be from zero to size (or capacity depending on your syntax) of the array minus 1. So if arr has size 10 then valid indexes will be from zero to 9.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396