一个C++小程序老调不好
改了一下,错误的地方标出来了,你对比一下就知道了 #include<iostream> #include<cmath> using namespace std; class Right_Angled_Triangle //声明类 { private: //以下为私有部分 float right_a; float right_b; float hypotenuse; public: //以下为公有部分 void set_rights() { cout<<"input right_a and right_b:"; cin>>right_a; cin>>right_b; } void out_hypotenuse() //定义公共函数out_hypotenuse() { hypotenuse=sqrt(right_a* right_a+right_b* right_b); cout<<"hypotenuse="<<hypotenuse<<endl; } //你的这地方多了个分号 }; int main()//你的缺了这一行。
{//这个左大括号是从下面提上来的。当然,下面的两个变量也可以定义到main()前面。 Right_Angled_Triangle triangle1,triangle2; //定义Right_Angled_Triangle的两个变量int main() triangle1。
set_rights(); triangle2。out_hypotenuse(); return 0; }。
也不说明具体什么问题,仍一堆代码算什么意思呢
你想调出什么来
答:printf("%.3f",a):详情>>
答:高手 很难的问题详情>>