I’m getting two errors in main that have me stumped:
- “no matching function for call”
- “invalid initialization of non-const reference of type ‘int&’ from a temporary of type ‘int*'”
Could anyone lend a hand? thanks!
header
#ifndef HEADER_H_INCLUDED
#define HEADER_H_INCLUDED
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cctype>
#include <cstdlib>
using namespace std;
void extern input(ifstream&, ofstream&, int&, int&);
#endif // HEADER_H_INCLUDED
main
#include "header.h"
using namespace std;
int main()
{
int grade;
int list[8];
ifstream inData;
ofstream outData;
inData.open("Ch9_Ex4Data.txt");
if (!inData)
{
cout << "Cannot open the input file."
<< endl;
return 1;
}
outData.open("DataOut.txt");
inData.get(grade); // << ERROR 1 HERE
while (inData)
{
input(inData, outData, grade, list); // << ERROR 2 HERE
}
output (outData, list)
return 0;
}
Error 1 is because inData.get() does not take an int, you should do
and the second is because list is actually an int* and not an int so the fourth parameter in input() should be an int* and not an int&