Vectors Help

Hello all,

I am trying to display the vector as well as get an exam average and a class average . The following is as close as I have got. Sorry I am new to C++. The following are the error

1. Vectors.cpp no match for 'operator<<' in 'std::cout << (&iter)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Student*, _Container = std::vector<Student, std::allocator<Student> >]()'

2. note C:\Dev-Cpp\include\c++\3.4.2\bits\ostream.tcc:63 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base&(*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]


#include <iostream>
#include <string>
#include <vector>
#include <conio.h>
#include <algorithm>


using namespace std;

struct Student{

string fName;
string lName;
vector<double>exams;
};


int main(){


const int NUM_EXAMS = 5;
Student tempFName, tempLName;
double tempExam;
int numStudents = 0;
vector<Student> sNames;
vector<Student>::iterator iter;


cout << "Number of students: " << endl;
cin >> numStudents;

for (int i = 0; i < numStudents; i++){
Student student;
cout << "Enter the first name for student #" << i+1
<< ": " << endl;
cin >> student.fName;
sNames.push_back(student);
cout << "the first name of the student is: " << student.fName << endl;

cout << "Enter the last name for student #" << i+1
<< ": " << endl;
cin >> student.lName;
sNames.push_back(student);
cout << "the first name of the student is: " << student.fName << endl;
for (int j = 0; j < NUM_EXAMS ; j++ ){
cout << "Enter the exam scores student #" << i+1 << " exam #" << j + 1
<< ": " << endl;;
cin >> tempExam;
student.exams.push_back(tempExam);

}// end of nested for loop

}//end of for loop

//display the vector

for (iter = sNames.begin(); iter != sNames.end(); iter++){
cout << *iter << " ";
cout << endl;
}// end of for loop

for (int i = 0; i < sNames.size(); i++){
cout << sNames.size() << " " ;
cout << endl;
}// end of the for loop


_getch();
return 0;

}//end of main
Topic archived. No new replies allowed.