+ 1
Why outputs 0*8*0 and 3*0*37(first and second outputs)? When i use the constructor works correctly(thrid output).
https://code.sololearn.com/c9uHLnUyOIV4/?ref=app Error in the code or the case in the application of the constructor?
5 Réponses
+ 5
Hi,
I fixed the code
https://code.sololearn.com/cAkA1JUxfol4/#cpp
let me know when to delete it. this is a pointer, and it was a pointer to an address. I added other values and the output was the same, that is how I figured it out. Also you first called the printing function and then the V one. as you can see I first use the V function and then I print,
Hope this helped you
+ 4
You call "print" method before you initialize the members through "V" method. If you call "V" method before you call "print", the output should be as expected. I would suggest to initialize the members by using constructor initializer list instead : )
Hth, cmiiw
+ 2
Your question better-matches this other code in your profile, not the one you have linked (its output is different).
https://code.sololearn.com/cFOss41XPPTp/?ref=app
+ 1
I guess compiler set default variables, but I'm not sure
+ 1
Thanks for the help