gpt4 book ai didi

c++ - CS2064 "term does not evalute a function taking 1 argument"?

转载 作者:行者123 更新时间:2023-11-28 00:11:58 25 4
gpt4 key购买 nike

我看过其他线程,他们说“这个或那个不是指针!!!”我真的不知道那是什么意思,我已经声明了 var ,所以这里有什么不起作用?我们正在编写一个程序来计算正方形的面积,顺便说一下,这也不是完整的代码!第 2 行也是错误点。

int s = ((line_one + line_two + line_three) / 2);
int area = sqrt((s - line_one)(s - line_two)(s - line_three));

cout << "The area of the triange is..." << area << endl;

这里是我声明其他变量的地方:

// Area of a Triangle

double x1 = 0;
double y1 = 0;
double x2 = 0;
double y2 = 0;
double x3 = 0;
double y3 = 0;
double x4 = 0;
double y4 = 0;
double x5 = 0;
double y5 = 0;
double x6 = 0;
double y6 = 0;

//line one points
cout << "enter point x1" << endl;
cin >> x1;
cout << "enter point y1" << endl;
cin >> y1;
cout << "enter point x2" << endl;
cin >> x2;
cout << "enter point y2" << endl;
cin >> y2;
const int line_one = sqrt((pow((x2 - x1), 2) + (pow((y2 - y1), 2))));

//line two points
cout << "enter point x3" << endl;
cin >> x3;
cout << "enter point y3" << endl;
cin >> y3;
cout << "enter point x4" << endl;
cin >> x4;
cout << "enter point y4" << endl;
cin >> y4;
const int line_two = sqrt((pow((x4 - x3), 2) + (pow((y4 - y3), 2))));

//line three points
cout << "enter point x5" << endl;
cin >> x5;
cout << "enter point y5" << endl;
cin >> y5;
cout << "enter point x6" << endl;
cin >> x6;
cout << "enter point y6" << endl;
cin >> y6;
const int line_three = sqrt((pow((x6 - x5), 2) + (pow((y6 - y5), 2))));
//Calculating the Area

int s = ((line_one + line_two + line_three) / 2);
int area = sqrt((s - line_one)(s - line_two)(s - line_three));

cout << "The area of the triange is..." << area << endl;


return 0;
}

最佳答案

这是一个简单的错误,您忘记在 sqrt() 函数调用中要相乘的事物之间添加 *。

int s = ((line_one + line_two + line_three) / 2);
int area = sqrt((s - line_one)*(s - line_two)*(s - line_three));

cout << "The area of the triange is..." << area << endl;

就像那样。它给了你指针错误,因为它认为你正在尝试调用一个函数,例如,(s - line_one) 将返回一个函数指针,而 (s-line_two) 将是该函数的参数。

关于c++ - CS2064 "term does not evalute a function taking 1 argument"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32533294/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com