小编wiz*_*izH的帖子

在c ++中使用一个简单的类,不工作?

我发现了一个想要尝试的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)

c++ class

-3
推荐指数
1
解决办法
2122
查看次数

标签 统计

c++ ×1

class ×1