Hey, I'm just started to learn that thing that calls Object-Oriented Programming. And to test myself desided to code simple "user"-object creator. So I has code like this.
first off: that functions returns nothing, hence void.
second off: the variables visible inside the function are only ones declared inside that function, which you got none, or members of the object.
First off, you should take a look at the cplusplus tutorials on
1) arrays,
2) functions, and
3) classes
Secondly...
1 2 3 4 5 6 7 8
int UID;
user iamuser[9]; //The array is only of size 9.
//This means you can only access iamuser[0] to iamuser[8]
cout << "\nEnter number from 1 to 9; that will be your UserID: "; //should say 0 to 8
cin >> UID;
iamuser[UID].UID=UID;
I recommend using do while loops to check if the user's input is valid.
1 2 3 4
do
{
cin >> UID;
}while(UID is not valid...);
As for displaying stuff: you misunderstand how to use variables in classes. Since displayData is user's function, it can access all of the variables and function in user.
1 2 3 4 5 6 7 8 9
//call your function like so
iamuser[USD].displayData();
//have your function like this...
int user::displayData()
{
cout << "\nYour Name: " << Name << endl;
//notice how I didn't say iamuser[UID].Name.
//it's just Name because there is only ONE Name for the ONE instance of this class.
}