How is my answer wrong? (C++ Sololearn Challenge) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How is my answer wrong? (C++ Sololearn Challenge)

Sololearn challenged me a C++ challenge so i accepted it. Both I and sololearn got almost every question wrong. (sololearn won because of that one question i timed out on because i overthinked it) But there are two questions that have a weird answer... no matter how much I think i can't think of a conclusion myself. So how am i wrong? First question with screenshot : https://www.sololearn.com/post/1728447/?ref=app Second question with screenshot : https://www.sololearn.com/post/1728450/?ref=app

17th Mar 2023, 8:14 PM
Dronto
Dronto - avatar
1 Answer
+ 5
For the first question: Both parameters got the reference of a, so a became 4 and the function returned 8. For the second question: Seems that member variables get initialised before the constructor body is executed.
18th Mar 2023, 12:06 AM
Lochard
Lochard - avatar