I can’t compile this code because the function declaration depends on the class declaration, and the class declaration depends on the function declaration. Please help.
#include <iostream>
using namespace std;
void simulate(Policy& p);
class Policy {
public:
Policy(int);
int x;
void eval();
};
int main() {
Policy p(23);
return 0;
}
Policy::Policy(int y) { x = y; }
void Policy::eval() { simulate(this); }
void simulate(Policy& p) { cout << ++p.x << endl; }
Place the prototype of your function below the definition of your class, but above the member functions.