Could someone please help me or point/explain to me why the error in
line 46 ?
////////////////////////Error message:////////////////////////////////
bash-2.05b$ g++ test3.cpp
test3.cpp: In function `int main()':
test3.cpp:46: error: request for member `print_data' in `ptrstudent',
which is
of non-aggregate type `Record_info*'
//////////////////////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;
const int MAX=50;
typedef double Number;
class Record_info {
public:
string bypassed;
string name;
int midterm;
Number quiz;
//double quiz;
Number final;
string testname;
void print_data();
};
void Record_info:: print_data(){
cout <<"name is : "<<name<<endl;
cout <<"Midterm is : "<<midterm<<endl;
cout <<"Quiz is : "<<quiz<<endl;
cout <<"Final is : "<<final<<endl;
cout <<"Testname is : "<<testname<<endl;
}
int main (void){
Record_info student[MAX],*ptrstudent;
ptrstudent = student;
ifstream in ("test2.txt");
string line;
string line2;
char buffer[40];
while (getline(in,line)){
if (line.find("#")!=string::npos)continue ;
istringstream stringstreams(line);
stringstreams>>ptrstudent->bypassed>>ptrstudent->name>>ptrstudent->midterm;
stringstreams>>ptrstudent->quiz>>ptrstudent->final>>ptrstudent->testname;
ptrstudent++;
}
for (ptrstudent=student; ptrstudent->midterm;ptrstudent++){
if (ptrstudent->bypassed.find("Y")!=string::npos)continue ;
double test= ptrstudent->quiz +100;
cout << "test is : "<<test<<endl;
ptrstudent.print_data(); //line 46
stringstream stream,stream2;
stream << "Do Add Bonus: "<<ptrstudent->name <<" "
<<ptrstudent->quiz;
string task(stream.str());
cout << task << endl;
stream2 <<"Do ExtraCredit: "<<ptrstudent->name<<" :"
<<ptrstudent->final<< " has done extra credit " <<ptrstudent->final+5;
string task2(stream2.str());
cout <<task2<<endl;
}
return 0;
}
//////////////////////////input file:
test2.txt//////////////////////////
###
Y Tony 90 -15.2 98.2 math
N Michael 95 17.2 92.2 physics
N Amy 82 13.9 78.2 accounting