Having some problems with Structures

Dec 8, 2010 at 2:57am
!!!!!I AM NOT WANTING ANYONE TO DO MY HOMEWORK...I JUST NEED SOME HELP WITH UNDERSTANDING!!!!!

I am writing a program for class and I keep running into a "no operator" error when I try to input information into my structure. The section I am having problems with are here


cin >> CLASS[I].SSN;

at the >> and I have tried to find information about what I did wrong and how to fix it from Bing, Google, and many other search engines, but to no avail. I am not looking for a strait answer, but if someone could explain what I did wrong and how to fix it and to explain a little bit more on how to use structures I will be ok. Thank you in advance.
Last edited on Dec 8, 2010 at 3:04am
Dec 8, 2010 at 3:13am
Can you put more sample code ? CLASS[I].SSN is a object variable with SSN as it's data member ? What is SSN data-type ? I inside the square bracket is a variable ? etc etc
Dec 8, 2010 at 3:18am
Ok i am using a structure named student with SSN, LAST_NAME, FIRST_NAME, and BALANCE_DUE within the structure. I also defined SSN as an int. The coding for the structure looks like this:

struct STUDENT
{
int SSN[99];
string LAST_NAME[99];
string FIRST_NAME[99];
double BALANCE_DUE[99];
}CLASS[99];

and the code where i have my cin is here:

cout << "Input SSN: " << endl;
cin >> CLASS[I].SSN;

where CLASS[I] is the array structure and .SSN should point back into the array for storage. What i dont understand is why the >> is telling me it is not an operantor when it is an operator. Can you explain why?
Dec 8, 2010 at 3:25am
1
2
3
4
5
6
7
struct STUDENT
{
  int SSN[99];
  string LAST_NAME[99];
  string FIRST_NAME[99];
  double BALANCE_DUE[99];
}CLASS[99];


Please note SSN is an ARRAY of int. So if you want to read from input stream into that you need array subscript.

cin >> CLASS[I].SSN[X]; //where X is a variable saying which array element to put an int value in that is retrieved from cin
Dec 8, 2010 at 3:28am
so pretty much what is going on is that SSN is an array within the structure and the structure is also an array of CLASS and when i am wanting to input the info i would need to point back to both the array of CLASS and the array of SSN?
Dec 8, 2010 at 3:33am
Yes. Not only SSN but LAST_NAME, FIRST_NAME, BALANCE_DUE are all arrays within the struct STUDENT. CLASS is an array of struct STUDENT.
Dec 8, 2010 at 3:41am
Thank you so much I understand it more and now I can fix my SWAPEM at the bottom of my program....Thank you so much.
Topic archived. No new replies allowed.