#include <iostream>
double towerHeight()
{
std::cout << "Insert the height of the tower";
double towerHeight{};
std::cin >> towerHeight;
return towerHeight;
}
int main()
{
double towerHeight {towerHeight()};
}
When in main, if i try to initialize the value “towerHeight” with the function “towerHeight()” i have an error.. but if i call my function “owerHeight” or something different, the problem disappear… why i cannot call variable and function the same?
I tried to change the name of the function and it works.`
New contributor
Jonathan Ragucci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.