Verwendung von cmath und iostream mit "using namespace"



  • Hallo!
    Ich bin noch ein völliger Neuling in C++.
    Warum funktioniert folgendes nicht?

    #include <iostream>
    #include <cmath>
    using namespace std;
    
    int main() {
        float zahl = 123;
        cout << pow(2,10);
    
        system("pause");
    }
    

    mit wxDevC++ unter Win xp bekomm' ich nur "call of overloaded `pow(int, int)' is ambiguous ". Häää??

    Gut cmath verwendet auch einen Namensraum std, aber in iostream gibt es die Funktion pow nicht. Also warum meckert er über Mehrdeutigkeit?



  • Hallo

    Mit iostream hat der Fehler nichts zu tun.
    Sondern pow erwartet als Argumente double, bei deinen ints findet erwohl eine zweite passende Funktion.cout

    So kannst du ihn zu double zwingen :

    << pow(2.0d,10.0d);
    

    bis bald
    akari


Anmelden zum Antworten