0

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 :(

1
  • 2
    Show the code that defines Name. Without it this code is nonsense. Commented Dec 5, 2016 at 20:55

1 Answer 1

1

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
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.