dimanche 22 juillet 2018

Does Pow() really need cmath header or does iostream include cmath?

I am confused why this code works without including

"#include <cmath>"

below is my code and it works without it.

// PowerApp.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

int main()
{
    std::cout << pow(2, 3) << "\n";
    return 0;
}

I referred What is the C++ function to raise a number to a power? which again confirms that we need it.

I checked definition of pow and it is part of cmath.h but it works as soon as I include <iostream.h>

Aucun commentaire:

Enregistrer un commentaire