Reputation: 1
Header file:
class Student
{
public:
int A[30];
//...
};
.cpp file:
// ...
for (i = 0; i < n; i++)
{
cout << "Name: ";
cin >> Name.A[i];
}
// ...
Member Reference base type 'int' is not a structure or union
I wanna give out all added names in a table at. I'm a C++ beginner - sorry :(
Upvotes: 0
Views: 44
Reputation: 117876
You need to instantiate an instance of your class. Then you can assign to the member variable of that class.
Student person; // Create a "Student" instance
for (i = 0; i < n; i++)
{
cout << "Name: ";
cin >> person.A[i]; // Assign to that Student's "A" variable
}
Upvotes: 1