C++ basics
English
Pertengahan
Test your knowledge in C++!
Keterangan
30
Soalan
15 saat
Setiap soalan
3:42
Masa purata
4.0
Skor Pertandingan
3.5
Kedudukan Komuniti
53
Peserta
16 komen
Holy Duck hakim
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 pengarang
I’m glad it helped! 💪
Little Skunk
question 12 with wrong explanation (variable x does not exist)
Holy Mule pengarang
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 pengarang
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 pengarang
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 pengarang
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
Ambil kuiz untuk tinggalkan komen