+ 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?

15th Jan 2019, 3:47 PM
Ch1p
Ch1p - avatar
5 odpowiedzi
+ 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
15th Jan 2019, 5:35 PM
notqueued
notqueued - avatar
+ 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
15th Jan 2019, 5:34 PM
Ipang
+ 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
15th Jan 2019, 5:34 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
I guess compiler set default variables, but I'm not sure
15th Jan 2019, 4:30 PM
Edin Hajdarevic
Edin Hajdarevic - avatar
+ 1
Thanks for the help
15th Jan 2019, 7:05 PM
Ch1p
Ch1p - avatar