#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <string>
using namespace std;
//const int MAX_SIZE = 10;
//char determine_grade(int smarks);
class student{
public:
student(); //constructor
~student(); //destructor
//char grade;
//set values
void set_mark(int);
void set_id(string);
void print_students_records(student, int);
//get values
int get_mark();
string get_id();
private:
int mark;
string id;
};
//void print_students_records(student s[], int size);
//void student::print_students_records(s[], int size){
void student::set_mark(int mark){
student::mark = mark;
}
void student::set_id(string id){
student::id = id;
}
int student::get_mark(){
return mark;
}
string student::get_id(){
return id;
}
void student::print_students_records(student s, int size){
cout<<"\n\nstudents, records"<<endl<<endl;
for (int i = 0; i < size; i++){
cout<<"id: "<<s[i].get_id(i)<<", marks: "<<s[i].get_mark(i)<<endl;//<<", grade: "<<sgrades[i]<<endl;
}
cout<<endl;
}
//void discard_line(ifstream &infile);
int main()
{
student s[8];
ifstream infile;
cout<<"This program determines the grades of students."<<endl;
infile.open("E:\\students.txt",ios::in);
if(!infile){
cerr<<"File could not be opened"<<endl;
exit(1);
}
//discard_line(infile);
int total_records = 0;
while(infile.good()){
for (int i = 0; i < total_records; i++){
infile >> s[i].set_id(i) >> s[i].set_mark(i);
total_records++ ;
}
infile.close();
print_students_records(s[], total_records);
system("PAUSE");
return 0;
}
}
i get the following errors while compiling
57 g:\copyof~1.cpp no match for `student &[int &]'
57 g:\copyof~1.cpp no match for `student &[int &]'
87 g:\copyof~1.cpp no matching function for call to `student::set_id (int &)'
42 g:\copyof~1.cpp
candidates are: void student::set_id(basic_string<char,string_char_traits<char>,__default_alloc_template<false,0> >)
95 g:\copyof~1.cpp parse error before `]'
what is the problem?