C++ basics
English
Intermediate
Test your knowledge in C++!
Description
30
Questions
15 sec
Per question
3:47
Average time
4.0
Contest Score
3.5
Community Rating
51
Participants
16 comments
Holy Duck judge
This test may have a higher chance of receiving a reward. Nominated for:

Educational explanations. 👍 Explanations cover why the correct answers are correct and why the wrong answers are wrong (when appropriate). E.g.: #q1, #q2, #q3
Hardy Snail
Nice quiz. Helped me refresh some of my C++ knowledge.
Holy Mule author
I’m glad it helped! 💪
Little Skunk
question 12 with wrong explanation (variable x does not exist)
Holy Mule author
You’re right. In the explanation it should be “a”, not “x”.
Quirky Quokka
Very nice! Remembered me I still have to revise my c++ basics😂
Small Lizard
How can you set the size of a static array?
You can use an int variable too.
Example: https://ideone.com/R8mreY
Holy Mule author
Yes, but it is not a standard. Some compilers compile that, but the program would not be portable anymore, since it could give some problems on another machine with a different compiler.
Small Lizard
Holy Mule So I think the answer is ambiguous and it is bad
Small Lizard
The memory for an object, dinamically created in a function:
Can be deallocated only using delete operator. It is NOT deallocated at the end of the program, if not explicitly done before
Proof: https://ideone.com/lWKjfJ. In this code, destructor won't be called.
Holy Mule author
As well explained here https://www.cplusplus.com/forum/general/263564/, "[...] deallocation is separate from destruction. Destruction is not actually about deallocation, but about releasing resources an object owns".
Every object allocated in the memory from the program, once it ends, is deallocated from the memory, since the stack is removed.
Small Lizard
Holy Mule OK, I agree
Ace Cock
#27 "What is the correct symbol to get the reference of an object?"
Operator & returns pointer, not reference. You don't need any operators at all to get reference to object.
Holy Mule author
Sure, but it also creates a reference https://www.tutorialspoint.com/cplusplus/cpp_references.htm
Ace Cock
Holy Mule I see what you mean, but the wording of the question still seems off. & is used to declare a reference, not to get it from object.
Smart Antelope
Take the quiz to leave a comment