HI: I am trying to access a variable from a different function to calculate height. There were no errors using xrandomAngle, however, there is a compiling error to use Voy, calculating height.
Call of Overloaded'pow(int&, int)' is ambiguous* is the error
Here is a part of my program that is having compiling errors.
Also, 2nd question: If I wanted to access correctAns in the main class to increment the number of correct answers, every time the user inputs the correct amount, what do I have to do to change that? Atm, it is a public static variable in Class Rocket (I got a compiling error from trying to access this variable in main class)--> its undeclared in main-how do i get it to be same in main and rocket class?
class Rocket
{
private:
int Voy;
int xrandomAngle;
staticconstint GRAV= -10, Voi = 100;
public:
Rocket();
int randomAngle();
void tutorial();
int calculateVoy();
int calculateHeight();
int rightRocket();
staticint correctAns;
};
//set correct answers back to zero
Rocket::Rocket()
{
correctAns == 0;
}
//for every correct answer, keeps track of number of correct answers
int Rocket::rightRocket()
{
return correctAns++;
}
int Rocket::randomAngle()
{
srand((unsigned)time(0));
// produces a random height with range 25-80
xrandomAngle = rand()%80+25;
return xrandomAngle;
}
int Rocket::calculateVoy()
{
Voy=Voi * (int)sin(xrandomAngle);
return Voy;
}
int Rocket::calculateHeight()
{
int height;
height = (-pow(Voy,2))/(2*GRAV);
return height;
}
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
usingnamespace std;
class Rocket
{
private:
int Voy;
int xrandomAngle;
staticconstint GRAV= -10, Voi = 100;
public:
Rocket();
int randomAngle();
void tutorial();
int calculateVoy();
int calculateHeight();
int rightRocket();
staticint correctAns;
};
//set correct answers back to zero
Rocket::Rocket()
{
correctAns == 0;
}
//for every correct answer, keeps track of number of correct answers
int Rocket::rightRocket()
{
return correctAns++;
}
int Rocket::randomAngle()
{
srand((unsigned)time(0));
// produces a random angle with range 25-80 degrees
xrandomAngle = rand()%80+25;
return xrandomAngle;
}
int Rocket::calculateVoy()
{
randomAngle();
Voy=Voi * (int)sin(xrandomAngle);
return Voy;
}
int Rocket::calculateHeight()
{
calculateVoy();
int height;
float h = (-pow(float Voy,2))/(2*GRAV); <-- NEW ERROR
height = (int) h;
return height;
}