小编use*_*381的帖子

在main中调用函数

我刚刚学习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功能.

c++ function

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

function ×1