我刚刚学习C++,我在这里有一些代码:
using namespace std;
int main()
{
cout<<"This program will calculate the weight of any mass on the moon\n";
double moon_g();
}
double moon_g (double a, double b)
{
cout<<"Enter the mass in kilograms. Use decimal point for any number entered";
cin>>a;
b=(17*9.8)/100;
double mg=a*b;
return mg;
}
Run Code Online (Sandbox Code Playgroud)
它编译,但当我运行它只打印出来:
This program will calculate the weight of any mass on the moon
但不执行该moon_g功能.