How to Access a Private Variable?
- by SoulBeaver
This question isn't meant to sound as blatantly insulting as it probably is right now.
This is a homework assignment, and the spec sheet is scarce and poorly designed to say the least. We have a function:
double refuel( int liter, GasStation *gs )
{
// TODO: Access private variable MaxFuel of gs and decrement.
}
Sound simple enough? It should be, but the class GasStation comes with no function that accesses the private variable MaxFuel. So how can I access it anyway using the function refuel?
I'm not considering creating a function setFuel( int liter ) because the teacher always complains rather energetically if I change his specification. So... I guess I have to do some sort of hack around it, but I'm not sure how to go about this without explicitely changing the only function in GasStation and giving it a parameter so that I can call it here.
Any hints perhaps?