在此范围内未找到 Findfactorial
Findfactorial was not found in this scope
本文关键字:Findfactorial 范围内 更新时间:2023-10-16
每次我运行Qt程序时,都会给出以下错误:
在此范围内未找到 Findfactorial
有人可以建议为什么吗?我的mainwindow.cpp
中有该功能
int findFactorial(int x){
if(x == 1){
return 1;
} else {
return x*findFactorial(x-1);
}
}
mainwindow.h
:
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
bool ok = false;
int findFactorial(int x);
~MainWindow();
private slots:
void on_clear_button_clicked();
void on_sqr_button_clicked();
void on_exp_two_button_clicked();
void on_pi_button_clicked();
void on_ceil_button_clicked();
void on_factorial_button_clicked();
private:
Ui::MainWindow *ui;
};
您必须使用范围解析运算符明确说明此函数属于哪个范围/命名空间。
int MainWindow::findFactorial(int x){
if(x == 1){
return 1;
} else {
return x*findFactorial(x-1);
}
}