im getting an error and I dont know why can anyone help.
this is the error......
[CODE=cpp]#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
ifstream in_file;
//class that holds student record information.
class records{
private:
string name;
float quizes[7];
float projects[6];
float exams[2];
float labs[14];
public:
void set_name(ifstre am& in_file);
void set_quizes(ifst ream& in_file);
void set_projects(if stream& in_file);
void set_exams(ifstr eam& in_file);
void set_labs(ifstre am& in_file);
float get_quizes(int val);
//float get_projects(in t val);
//float get_exams(int val);
//float get_labs(int val);
};
void average_quizes( records,float&) ;
int main()
{
cout.width(10);
cout << "No." << " " << "Name" <<" " << " " << " Quiz" << " " << "Project" << " " << "Exam" << " " << "Lab" << " " << "Total" << " " << "Grade" << endl;
cout << "---------------------------------------------------------------" << endl;
cout << endl;
records grades;
ifstream in_file;// Define a file input stream and open the file
in_file.open("r ecord.txt"); //opening file
if (in_file.fail() )
{
// Failed to open the file (file doesn't exist or isn't readable)
cout << "Could not open file: "<< "\n";
exit(1);
}
int counter = 1;
float quiz_average = 0;
while(in_file)
{
average_quizes( grades,quiz_ave rage);
cout << quiz_average;
cout << counter;
}
return 0;
}
void records::set_na me(ifstream& in_file)
{
in_file >> name;
}
void records::set_qu izes(ifstream& in_file)
{
for (int i = 0; i < 7; i++)
{
in_file >> quizes[i];
}
}
void records::set_pr ojects(ifstream & in_file)
{
for (int i = 0; i < 6; i++)
{
in_file >> projects[i];
}
}
void records::set_ex ams(ifstream& in_file)
{
for (int i = 0; i < 2; i++)
{
in_file >> exams[i];
}
}
void records::set_la bs(ifstream& in_file)
{
for (int i = 0; i < 14; i++)
{
in_file >> labs[i];
}
}
//accessing quiz values.
float records::get_qu izes(int val)
{
if(val < 7)
return quizes[val];
else
return quizes[0];
}
//printing out quizes.
void average_quizes( records* obj,float& quiz_average)
{
for (int i = 0; i < 7; i++)
{
obj-> get_quizes(i);
quiz_average = i + quiz_average;
quiz_average = (quiz_average/7);
}
}[/CODE]
this is the error......
Code:
/tmp/ccxaenRY.o(.text+0x375): In function `main': : undefined reference to `average_quizes(records, float&)' collect2: ld returned 1 exit status
[CODE=cpp]#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
ifstream in_file;
//class that holds student record information.
class records{
private:
string name;
float quizes[7];
float projects[6];
float exams[2];
float labs[14];
public:
void set_name(ifstre am& in_file);
void set_quizes(ifst ream& in_file);
void set_projects(if stream& in_file);
void set_exams(ifstr eam& in_file);
void set_labs(ifstre am& in_file);
float get_quizes(int val);
//float get_projects(in t val);
//float get_exams(int val);
//float get_labs(int val);
};
void average_quizes( records,float&) ;
int main()
{
cout.width(10);
cout << "No." << " " << "Name" <<" " << " " << " Quiz" << " " << "Project" << " " << "Exam" << " " << "Lab" << " " << "Total" << " " << "Grade" << endl;
cout << "---------------------------------------------------------------" << endl;
cout << endl;
records grades;
ifstream in_file;// Define a file input stream and open the file
in_file.open("r ecord.txt"); //opening file
if (in_file.fail() )
{
// Failed to open the file (file doesn't exist or isn't readable)
cout << "Could not open file: "<< "\n";
exit(1);
}
int counter = 1;
float quiz_average = 0;
while(in_file)
{
average_quizes( grades,quiz_ave rage);
cout << quiz_average;
cout << counter;
}
return 0;
}
void records::set_na me(ifstream& in_file)
{
in_file >> name;
}
void records::set_qu izes(ifstream& in_file)
{
for (int i = 0; i < 7; i++)
{
in_file >> quizes[i];
}
}
void records::set_pr ojects(ifstream & in_file)
{
for (int i = 0; i < 6; i++)
{
in_file >> projects[i];
}
}
void records::set_ex ams(ifstream& in_file)
{
for (int i = 0; i < 2; i++)
{
in_file >> exams[i];
}
}
void records::set_la bs(ifstream& in_file)
{
for (int i = 0; i < 14; i++)
{
in_file >> labs[i];
}
}
//accessing quiz values.
float records::get_qu izes(int val)
{
if(val < 7)
return quizes[val];
else
return quizes[0];
}
//printing out quizes.
void average_quizes( records* obj,float& quiz_average)
{
for (int i = 0; i < 7; i++)
{
obj-> get_quizes(i);
quiz_average = i + quiz_average;
quiz_average = (quiz_average/7);
}
}[/CODE]
Comment