For class we are making a program that analytically and empirically calculates T(n). Our functions are supposed to be in a separate class f, and we are supposed to use a function to read input from a file to use as "n" and call the functions to print the values. I am getting this error when I try to call the analysis functions as parameters for my print function:
p03.cpp:61:23: error: expected primary-expression before â.â token
p03.cpp:61:34: error: expected primary-expression before â.â token
I am sure this is a silly typo somewhere but I can't find it. And yes I have included F03.h in p03.cpp and in F03.cpp. Here is the code causing the error:
void analysis(istream& i) {
//Code Fragment 0 analysis
PrintHead(cout, "Code Fragment 0");
for(;;) {
int n;
i >> n;
if (i.eof()) break;
//Next line is line 61
PrintLine(cout, n, f.af00(n), f.ef00(n));
}
}
Here are the print functions also in p03.cpp:
void PrintHead(ostream& o, string title) {
o << title << endl;
o << setw(20) << "n" << setw(20) << "Analytical" << setw(20) << "Empirical";
o << endl;
}
void PrintLine(ostream& o, int n, int a, int e) {
o << setw(20) << n << setw(20) <<a << setw(20) << e << endl;
}
Here is class declaration for f in F03.h:
#ifndef F03_h
#define F03_h 1
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <fstream>
#include <string>
class f {
public:
int ef00(int n);
int af00(int n);
};
#endif
Here are the implementations:
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <fstream>
#include <string>
#include "F03.h"
int f::ef00(int n)
{ int t=0;
int sum=0; t++;
int i=0; t++;
while (i<n) { t++;
sum++; t++;
i++; t++;
} t++;
return t;
}
int f::af00(int n)
{ return 3*n+3;
}
Any insight is greatly appreciated!