I'm having trouble compiling my code in terminal the error specifically to cmath.
Here is the error codes.
area_calculator.cpp:45: error: call of overloaded `pow(int&, int)' is ambiguous
/usr/include/bits/mathcalls.h:154: error: candidates are: double pow(double, double)
/usr/include/g++/cmath:512: error: long double std::pow(long double, int)
/usr/include/g++/cmath:508: error: float std::pow(float, int)
/usr/include/g++/cmath:504: error: double std::pow(double,int)
/usr/include/g++/cmath:495: error: long double std::pow(long double, long double)
/usr/include/g++/cmath:486: error: float std::pow(float,float)
When I run the code in cpp.sh it works well, but after compiling there is an error.
Here is my code
#include <iomanip>
#include <iostream>
#include <cmath>
int main() {
int optionNumber;
int radius;
const double pi = 3.14159;
double circleArea;
int length, width;
double rectangleArea;
int base, height;
double triangleArea;
if (n == 1) {
std::cout << std::fixed;
std::cout << std::setprecision(2);
circleArea = pi * pow(radius, 2);
} else if (n == 2) {
std::cout << std::fixed;
std::cout << std::setprecision(2);
rectangleArea = length * width;
} else if (n == 3) {
std::cout << std::fixed;
std::cout << std::setprecision(2);
triangleArea = (base * height * 0.5);
}
}
Of course, there are some codes missing since this is a homework assignment, but I think this should help.
Thanks in advance.