0
Why is this output wrong?
I'm trying to make a converter by using class and object. There's no error message but the output is not what i expected. https://code.sololearn.com/c3B2CRF7AUX6/?ref=app
4 Answers
+ 1
remove spaces before ()
jarak.setMil(10);
jarak.getmil()
jarak.getkilmet()
jarak.getDist()
change declaration
int km;
change method
int getDist() {
km = kilmet*mile;
return km;
}
0
Thanks for your help!
But I'm still curious, so why is it producing different value?
I don't understand đ€
Care to elaborate?
0
Incorrect initialization of "km".
"mile" at this moment has no value
0
Oh i see, so the x haven't been assigned to the mile when the program jump to "private:" to initialize mile kilmet and km. Ok i got it. Thanks again.