I'm making a calculator based on the library and I wanted to implement powers, however my code seems to completely skip the powering process and I have no idea why.
The code below is a fraction of my code and I hope that is enough for possible advices and help.
float Kalkulator::mnozenie()
{
float wynik;
if (ObecnElem == "(")
{
nastepny();
wynik = dodawanie();
nastepny();
}
else
{
wynik = intZmiana(ObecnElem);
nastepny();
}
return wynik;
}
void Kalkulator::nastepny()
{
listElem.pop_front();
if (!listElem.empty())
{
ObecnElem = listElem.front();
}
else
{
ObecnElem = string();
}
}
float Kalkulator::potegowanie()
{
float wynik = mnozenie();
while (ObecnElem == "^")
{
if (ObecnElem == "^")
{
nastepny();
float p = pow(wynik, mnozenie());
wynik = p;
cout << "\n";
cout << wynik;
copy(begin(listElem), end(listElem), ostream_iterator<string>(cout, ""));
cout << "\n";
}
}
return wynik;
}