c++ - KSP DELTA V 查找器 : Why does C++ assume that log( ) is a function?

标签 c++ trigonometry logarithm

我正在尝试创建一个程序来计算我的 Kerbal Space Program 游戏的 Delta-V,而 C++(在 Eclipse IDE 中运行)不允许使用 log() 除非我正在尝试调用一个函数。非常感谢您的帮助!你真好。`

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    cout << "Hello. Welcome to the Kerbal Space Program Delta V Calculator. \n";
    cout << " \n";
    cout << "Note that each stage must use the same engine for this calculator.";
    cout << "\n";
    cout << "\nHow many stages make up your rocket? :";
    int stageNumber;
    cin >> stageNumber;
    //cout << "Your rocket has " << stageNumber << " stages.\n";
    cout << "\n\nStart from the bottom stage, please. ";
    //ACTUAL DELTA V CALCULATIONS
    for(int currentStage = 1; currentStage <= stageNumber; currentStage = currentStage + 1){
        cout << "What is the total mass of this stage? :";
        int totalMass;
        cin >> totalMass;
        cout << "What is the fuel mass of this stage? :";
        int fuelMass;
        cin >> fuelMass;
        cout << "\n";
        int dryMass;
        dryMass = totalMass - fuelMass;
        cout << "Your dry mass is" << dryMass << "\n";
        cout << "\n";
        cout << "Give the specific impulse of this stage's engine. \n";
        int iSP;
        cin >> iSP;
        cout << "Here is the Delta V of your rocket.\n";
        int deltaMass;
        deltaMass = totalMass/dryMass;
        int deltaV;
        deltaV = iSP * log(deltaMass);
        cout << deltaMass

        exit(0);
    }

}

`

最佳答案

log() 是 C 标准库中的一个函数,它取一个数的自然对数。该名称实际上是保留的——选择其他名称。

关于c++ - KSP DELTA V 查找器 : Why does C++ assume that log( ) is a function?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25496046/

相关文章:

c++ - CRTP 中 shared_ptr 的隐式向下转换

c++ - 如何隐藏 C++ 静态库中的符号?

java - 如何将物体缓慢平移到某个位置(以便可以看到)

algorithm - 如何获得圆的下界和上界半径?

algorithm - 深度快速排序的复杂性

c++ - Win32 的用户界面控件

c++ - 链表中的运算符重载 <<

iphone - 确定圆上两点相对于圆心的夹角

WPF 和 Oxyplot : graph with CategoryAxis and LogarithmicAxis

python - 如何预处理数据来计算均方根对数误差?