Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ Quiz

Started by Kamron Nov 23, 2004 at 6:18 PM 56 replies 9.6k views
Original Post
Kamron
Kamron
I did 2 C++ quiz. As my friends liked them a lot I though I can share it with your guys as well :) http://www.kamron.net/english/quiz.php They are called "Basic knowledge in C++" and "Intermediate C++". If you don't like quiz, sorry for disturbing you, nothing interesting in this thread then I suppose ;) Feel free to tell us your score and what you failed/succeeded PS: DON'T READ answers if you haven't done the test, it's likely some answers will be given :) Have fun Jeremy www.kamron.net
Jeremy Chatelainewww.kamron.net
technomancer
technomancer
fantastic work ... just what i was looking for +++
ontheheap
ontheheap
Neat. I scored 9/10 on the basic quiz. I missed number seven (about templates). I'll take the intermediate one now. This is fun [grin]

Edit: I did bad on the intermediate test. No surpise though!
dave
dave
Beginner: Blimey, i only scored 3/10, whats going on...
Inter: 5/10

I could swear that some of the beginner answers seem worn ghtough, oh well,

ace
Enigma
Enigma
10/10 on both [lol]

A few issues (spoilers if you haven't taken the quiz):
Basic quiz:
Q 3. Slightly misleading. You could argue that you "should" declare the destructor as virtual, but you only need to if you're going to delete the object polymorphically.
Q 4. Compilers probably can (and do) optimise the third option to the same machine code as the first and in certain cases do the same with the second.
Q 5. Technically you don't force the subclasses to reimplement the function, you just force them to reimplement them if the subclass needs to be instantiated.

Intermediate quiz:
Q 5. This is implementation defined. There is no guarantee that the overhead will be exactly four bytes.
Q 9. The answer is one way of doing it, but you could specialise on any type for the second template parameter.

Good quizes though.

Enigma
Alpha_ProgDes
Alpha_ProgDes
ha!
i got 10/10 [smile]
i guess on 8 and 9.
that static was a little hard.
Beginner in Game Development?  Read here. And read here.  
twanvl
twanvl
Nice, but:
By default:Struct A{};is equivalent to:Class A {};Class A {public: };

It is equavalent to both, all are syntax errors, since neither class nor struct is a keyword. Also, class A{}; and class A{public:}; are exactly the same, maybe add a member?

Quote:

Which incrementation of i is faster?
++i;
i++;
i = i + 1;

It depends on the type of i, for basic types, each will be as fast as the others. For classes it depends on the implementation, altough ++i is usually the fastest, this is not guaranteed.

Quote:

What is not true when using templates:
Syntax error like missing ; inside function are shown only when the template is used.

I am not sure the standard guarantees this (never read it)

But this is just nitpicking.
Zakwayda
Zakwayda
9/10 - 9/10, which I was pretty happy with! Easy stuff for a pro, I suppose, but I found some of it challenging. Plus:

*Spoiler*

I made an educated guess on c->B::Function(); and got it right - I guess that's valid syntax, although I'd never seen it before. So I learned something new!

Cool quizes! (Although I'd hate to see the 'advanced' quiz...)
Rhaal
Rhaal
Those questions are definately lacking detail.
- A momentary maniac with casual delusions.
skalco6
skalco6
Nice exercise for all of us here! thx
I scored 8/10 & 7/10, not that bad.
baddogj
baddogj
Ah Yeah! I got 10/10 on both tests.
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="88" height="70" id="H2lvl" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="http://www.ironhive.com/CFCs/H2lvl.swf?gamertag=jBaddog" /> <param name="quality" value="high" /> <param name="wmode" value="transparent"> <embed src="http://www.ironhive.com/CFCs/
DigitalDelusion
DigitalDelusion
I got 9/10 thanks to this question:
Quote:

By default:
Struct A
{
};
is equivalent to:
Class A {};
Class A {public: };
None of these 2


And really to be nitpicky about it there's one thing that makes the correct answer neither.

In the case of inheritance struct defaults to public inheritance while class defaults to private and in that respect they're not equvivalent although that answer requires some more thought to come to since it's not illustrated in the question.

edit: 10/10 on the intermediate though =)

good job with the quizes :)
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
robinei
robinei
Basic: 9/10. Intermediate: 10/10.
chollida1
chollida1
The asnwer to 3 for mutable as far as I'm aware is to tell the compile that a variable can change so don't cache its value. The test claims its to change constness. According to the C++ spec that is wrong.

10.2.7.2
" The storage specifier mutable specifies that a member should be stored in a way that allows updating"

ie. that's how you'd declare a variable that can be modifed from multiple threads in gcc and VS.net. whether its const or not.

What's your reasoning for disagreeing with the spec??

Good test by the way:)

CHeers
Chris
CheersChris
DigitalDelusion
DigitalDelusion
Quote:
Original post by chollida1
The asnwer to 3 for mutable as far as I'm aware is to tell the compile that a variable can change so don't cache its value.


You're talking about volatile not mutable.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
Cold_Steel
Cold_Steel
A few qualms I have.

Beginner:
1. Class and Struct should be lowercase
4. Speed is not an intrinsic feature of a language, and therefore is not related to the syntax or semantics of the language itself.

Intermediate:
5. Sounds like this could be compiler specific. Check it out.
7. This could conceivably be compiler specific too.

Just some thoughts...
______"Man is born free, and everywhere he is in chains" - J.J. Rousseau
JimPrice
JimPrice
10 and 9 - got the explicit keyword wrong (haven't used it in ages). Agree with most of the previous points made.

Quote:

Quote:

Which incrementation of i is faster?
++i;
i++;
i = i + 1;



It depends on the type of i, for basic types, each will be as fast as the others. For classes it depends on the implementation, altough ++i is usually the fastest, this is not guaranteed


I thought ++i was faster as it didn't have to create a temporary, whereas i++ does. Am I wrong?

Jim.
DigitalDelusion
DigitalDelusion
Quote:
Original post by JimPrice
I thought ++i was faster as it didn't have to create a temporary, whereas i++ does. Am I wrong?


No, that's the basic reasoning but with instruction reordering or smart register allocation you can't actually say that it's sure to be that way, but for user types like iterators it's almost always the case, doesn't hurt to be on the safe side :)
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
chollida1
chollida1
Digital Dellusion is right. I was mistaken:)

My bad

Cheers
Chris
CheersChris

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.