"expected unqualified-id" 这就是它所说的一切
"expected unqualified-id" Thats all it says
本文关键字:expected unqualified-id 更新时间:2023-10-16
所以我正在尝试用c ++为我的编程类编写代码。我们目前正在尝试使用牛顿-拉夫森方法找到三阶多项式的 3 个根。我收到一个错误,显示"预期的非限定 id"。这就是它所说的一切。在此之下,计算机将胡萝卜放在括号下。我一直在为这个错误而苦苦挣扎,所以任何建议都会很棒!我将发布下面的代码。
#include <iostream>
#include <cmath>
using namespace std;
double nrmethod(int r1, double fr1, double dr1fr1, int imax, double es);
int main ()
{
int sxx=10, sxy=14, sxz=25, syy=7, syz=15, szz=16;/* declaring integers to calculate the coefficients of the algebraic equation. this algebraic equations roots are the values we are looking for*/
int I;
int II;
int III;/*delcaring the coefficents of the algebraic equation*/
I=sxx+syy+szz;
II=(sxx*syy)+(sxx*szz)+(syy*szz)-(pow(sxy,2))-(pow(sxz,2))-(pow(syz,2));
III=(sxx*syy*szz)-(sxx*pow(syz,2))-(syy*pow(sxz,2))-(szz*pow(sxy,2))+(2*sxy*sxz*syz);/*solving for the coefficents of the algebraic equation*/
cout << I << ", " << II << ", " << III << endl; /*displaying the coefficients of the algebraic equation*/
int imax=100;
double es=0.01;
double dr1fr1;
double fr1;
int r1;
cout <<"enter guess for the root";
cin >> r1;
double r = nrmethod(r1, fr1, dr1fr1, imax, es);
cout << r << std::endl;
return 0;
}
double nrmethod(int r1, double fr1, double dr1fr1, int imax, double es);{
double fr1=pow(r1,3)-I*pow(r1,2)+(II*r1-III);
double dr1fr1= 3*pow(r1,2)-(2*I*r1)+II;
do
int k=1;
if(k<= imax){
k++;
r2=r1-(fr1/dr1fr1);
if r2 !=0 then int er=(abs(r2-r1)/abs(r2))*100;
if(er<es){end do}
else {return r2}
}
cout << r2;
return 0;
}
编译器会告诉您错误是什么,以及错误在哪里:
a.cpp:40:73: error: expected unqualified-id before '{' token
double nrmethod(int r1, double fr1, double dr1fr1, int imax, double es);{
^
在本例中,为无关分号。如果你想成为一名程序员,你必须学会注意编译器告诉你的内容。
相关文章:
- 对象声明中的模板"error: expected expression"
- 在C++中使用 Catch 测试框架编译错误"error: expected ';' at end of declaration list"
- Arduino无法编译名为SP:"Expected ')' before '(' token"的变量
- 为什么我的功能在使用 goto 时会给我带来"expected primary-expression before '}' token"?
- 为什么我会"error: expected expression"?
- 错误消息"expected expression"....有人知道它为什么这么说吗?
- C++中的"expected unqualified-id"错误是什么?
- 我正在尝试创建一个枚举,但得到了"identifier expected error"
- 如何修复此错误"expected primary expression before 'int'"?
- 为什么在main()之前断言会导致语法错误"error: expected ')' before numeric constant"?
- "expected a '>'"类模板专业化?
- 如何修复"expected a declaration"?
- 使用结构和数组时的"expected primary expression before '.' token"
- 如何解决"Expected expression before " = " token"?
- Rcpp 'candidate function has different number of parameters (expected 0 but has 1)'
- 错误:创建模板类时"expected unqualified-id before '{' token"
- C++:"Expected '(' for function-style cast or type construction"错误
- NDK 构建中的异常"error: expected ';' after top level declarator"
- C++:将运算符作为参数传递会导致错误"expected an identifier"
- 在编译main.cpp:3:1时,我一直得到这个错误:error: ' do '之前的expected unqual