我发现了一个想要尝试的begginers c ++挑战.但是,下面的代码说它在编译时包含错误.如果我一次尝试一行,它会在最后的第一个类定义中退出...我不知道什么是错的:)
#include <iostream>
using namespace std;
class Polynomial {
int a, b, c, functionValue;
public:
Polynomial (int, int, int);
static void functionValue(Polynomial);
};
Polynomial::Polynomial (int x, int y, int z) {
a = x;
b = y;
c = z;
}
void Polynomial::functionValue(Polynomial x) {
for (int i = 0; i < 5; i++) {
x.functionValue = x.a * pow(i, 2) + x.b * i + x.c;
cout << "The value of the function for x = " …Run Code Online (Sandbox Code Playgroud)