When one calls a function, it receives
copies of the arguments. To fix your situation, pass the parameters by reference:
void operations( Circles& sphere) {
The operations function relies on the menu function being called immediately before it, which isn't ideal. The code could break quite easily if modified. I like to put the switch and menu function call inside a while loop controlled with a boolean Quit:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
bool Quit = false;
while (!Quit) {
menu(); // with quit option
// get input
switch(input) {
// cases
4: // Quit case
Quit = true;
break;
default:
// default behaviour
} // end switch
} // end while
|
You have the PI const in there twice. You could make it global, but a better practise is to put it in a header file.
constexpr
is stronger than const, so use that if you can.
Use
const
wherever you can, especially for function parameters:
Circles::Circles(const double r, const int c1, const int c2) { // why are the centre values int?
Finally I like to put digits before and after the decimal point to reinforce the idea that it is a double:
2.0 * PI * radius;
It can help avoid integer math especially with division, and it at least saves the compiler an implicit conversion from integer to double.