【发布时间】:2020-03-29 16:52:10
【问题描述】:
我正在尝试使用类创建一个程序,通过用户输入,可以执行勾股定理的操作,但我收到此错误:
错误(活动)E0304 没有重载函数“getline”的实例与参数列表匹配
这是我的代码:
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
class PythagoreanTheorum
{
public:
double a;
double b;
double c;
void seta(double A)
{
a = A;
}
void setb(double B)
{
b = B;
}
void setc(double C)
{
c = C;
}
double calcAreea()
{
return a * pow(a, 2) + b * pow(b, 2) == c * pow(c, 2);
}
};
int main()
{
//Define one right triangles
PythagoreanTheorum righttriangle1;
double a;
double b;
double c;
cout << "Enter the value for a: " << endl;
righttriangle1.a = getline(cin, a);
cout << "Enter the value for b: " << endl;
righttriangle1.b = getline(cin, b);
cout << "Enter the value for c: " << endl;
righttriangle1.c = getline(cin, c);
}
【问题讨论】:
-
这能回答你的问题吗(今天没有标记):stackoverflow.com/q/5844309/12448530
-
为什么不使用 cin 输入 a、b 和 c 的值
-
这能回答你的问题吗? Trying to use int in getline
-
另外,calcAreea() 不正确,这是为了勾股定理,对吧? a^2 + b^2 = c^2?