I am new to the C++ scene and I am wanting to print the contents of my Vector out into the screen. I am having trouble finding the right code of being able to print what is in the vector out, as I keep getting the error: "error: invalid operands to binary expression ('ostream' (aka 'basic_ostream') and 'value_type' (aka 'S_type'))|"
I'll give all of the code I have. I have tried different things trying to get to print the vector such as "cout<
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
enum G_type {Dandy, Okay, Weak, Undefined}; // enumerated type for grades
struct S_type // defines a student record
{
int ID;
int Score;
G_type Grade;
};
vector<S_type> Roll; // vector to store student records
// declare all function prototypes
void Init_Roll ( vector<S_type>& R);
int Avg_Score (vector<S_type> R);
void Assign_Grades (vector<S_type>& R, int Avg);
void Print_Roll (vector<S_type> R);
int main()
{
for(int i=0; i<Roll.size();i++)
cout << Roll[i];
return 0;
} // end of main
// define all your functions below
void Init_Roll (vector<S_type>& R){
S_type s; //to assemble temporary record
//use the test data provided to insert 12 student records, one by one;
s.ID=108;s.Score=85;s.Grade=Undefined;
R.push_back(s);
s.ID=122;s.Score=73;s.Grade=Undefined;
R.push_back(s);
s.ID=130;s.Score=62;s.Grade=Undefined;
R.push_back(s);
s.ID=140;s.Score=70;s.Grade=Undefined;
R.push_back(s);
s.ID=147;s.Score=80;s.Grade=Undefined;
R.push_back(s);
s.ID=240;s.Score=92;s.Grade=Undefined;
R.push_back(s);
s.ID=320;s.Score=88;s.Grade=Undefined;
R.push_back(s);
s.ID=325;s.Score=58;s.Grade=Undefined;
R.push_back(s);
s.ID=350;s.Score=67;s.Grade=Undefined;
R.push_back(s);
s.ID=400;s.Score=79;s.Grade=Undefined;
R.push_back(s);
s.ID=420;s.Score=85;s.Grade=Undefined;
R.push_back(s);
s.ID=500;s.Score=72;s.Grade=Undefined;
R.push_back(s);
}//end of Init_Roll
int Avg_Score (vector<S_type> R){
int sum = 0;
for(int k=0;k<R.size();k++)
sum = sum + R[k].Score;
return sum/R.size();
}//End of Avg_Score
void Assign_Grades (vector<S_type>& R, int Avg){
for(int k=0;k<R.size();k++){
if(R[k].Score<Avg-10)
R[k].Grade = Weak;
else if(R[k].Score>Avg+10)
R[k].Grade = Dandy;
else
R[k].Grade = Okay;
}
}//End of Assign_Grades
void Print_Roll (vector<S_type> R){
for(int k=0;k<R.size();k++){
switch(R[k].Grade){
case Dandy: cout<<"Dandy";
break;
case Okay: cout<<"Okay";
break;
case Weak: cout<<"Weak";
break;
case Undefined: cout<<"Undefined";
break;
}
}
for(int i=0;i<R.size();i++){
cout<<"ID: " << R[i].ID << " Score: " << R[i].Score << cout << " Grade: " << R[i].Grade << '\n';
}
}//End of Print_Roll
Question is, how do I get the Roll vector to print out to the screen?