KSP DELTA V FINDER:为什么C++认为log()是一个函数?

Jet*_*mmy 1 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);
    }

}
Run Code Online (Sandbox Code Playgroud)

`

dus*_*uff 6

log()是C标准库中的函数,它采用数字的自然对数.该名称被有效保留 - 选择其他东西.

  • 值得注意的是,如果他不是"使用命名空间std;"就可以避免这种情况 (2认同)