Forum Navigation:

magazine

FORUMS > Careers Forum < refresh >
Topic Title: Advanced C++ Interview Topics / Questions Wanted
Created On Fri Jan 15, 10 10:55 PM
Topic View:

Pages: [ 1 2 >> Next ]
View thread in raw text format


kmg
Junior Member

Posts: 18
Joined: Dec 2006

Fri Jan 15, 10 10:55 PM
User is offline

Hi forum-

I'm gearing up for an interview (C++). I would appreciate any suggestions on advanced topics to review and / or specific interview questions you've come across that you found advanced or tricky (and at least reasonably likely to reappear - i.e. a good interview question).

Kind Thanks for your suggestions.

kmg
 
Reply
   
Quote
   
Top
   
Bottom
     



Cuchulainn
Senior Member

Posts: 37513
Joined: Jul 2004

Sat Jan 16, 10 01:29 PM
User is offline

I suppose advanced memory stuff (raw, smart?) and *,&,++.

Maybe Singleton pattern, some multithread. But maybe not.

-------------------------
www.datasimfinancial.com
 
Reply
   
Quote
   
Top
   
Bottom
     



outrun
Senior Member

Posts: 16398
Joined: Jun 2002

Sat Jan 16, 10 02:44 PM
User is offline

sensible topics would be to test if you know what's available in STL (containters, itterators, algorithms), BOOST so that you don't reinvent the wheel. Also templates & meta programming are important knowledge domains.
 
Reply
   
Quote
   
Top
   
Bottom
     



Cuchulainn
Senior Member

Posts: 37513
Joined: Jul 2004

Sat Jan 16, 10 03:52 PM
User is offline

Quote

Originally posted by: outrun
sensible topics would be to test if you know what's available in STL (containters, itterators, algorithms), BOOST so that you don't reinvent the wheel. Also templates & meta programming are important knowledge domains.


TMP is *very* advanced and is not generally known. Besides, how do you support TMP code, it's unreadable, especially when it is not documented.

@kmg
Will the interviewee be maintaining C++ code and/or developing green fields?

-------------------------
www.datasimfinancial.com

Edited: Sat Jan 16, 10 at 03:55 PM by Cuchulainn
 
Reply
   
Quote
   
Top
   
Bottom
     



kmg
Junior Member

Posts: 18
Joined: Dec 2006

Sat Jan 16, 10 06:24 PM
User is offline

Hi Cuchulainn, Outrun-

Actually, I'm the interviewee. The gig is a quantitative developer job (C++) in credit trading (analytics, pricing, risk, and trade capture, etc). I have some (non-recent) experience with the STL. So, I'm aware of it and some of what it provides.

My aim right now is to anticipate to the extent practical the most likely aspects of C++ this assessment might entail. I'm very comfortable with "C-derived linuistics". But it's been a while since I've been a regular programmer - and assessments are unforgiving. This one is given via IKM (International Knowledge Measurement - ikmnet.com).

I have to imagine that it's got to run through relatively standard elements of C++ to a fair extent, but there must be some amount - say 35% to 50% of advanced material. My thought is to try and anticipate this advanced material...

kmg
 
Reply
   
Quote
   
Top
   
Bottom
     



Cuchulainn
Senior Member

Posts: 37513
Joined: Jul 2004

Sat Jan 16, 10 08:57 PM
User is offline

Quote

I have to imagine that it's got to run through relatively standard elements of C++ to a fair extent, but there must be some amount - say 35% to 50% of advanced material. My thought is to try and anticipate this advanced material...


The crunch issue is honesty: I don't know interviewee's C++ background (new, novice etc.), and what have you done in C++ to date. One thing is sure and that is it takes 5 minutes to know how much one does know. Drawing up a list of what you are/are not comfortable with is a good start.


Quote

I'm very comfortable with "C-derived linuistics

what?

-------------------------
www.datasimfinancial.com

Edited: Sat Jan 16, 10 at 09:43 PM by Cuchulainn
 
Reply
   
Quote
   
Top
   
Bottom
     



kmg
Junior Member

Posts: 18
Joined: Dec 2006

Sat Jan 16, 10 11:18 PM
User is offline

I meant to say "linguistics" - or rather semantics.
 
Reply
   
Quote
   
Top
   
Bottom
     



yurakm
Member

Posts: 149
Joined: May 2005

Sun Jan 17, 10 09:06 PM
User is offline


I assume that the interview will be mostly devoted to a numerical methods and financial models, not to a C++ proper. However:


It is impossible to learn C++ fast, unlike C. Depending on how much time you have to prepare (one weekend or two weeks, for example), I would suggest to read / understand about:

- good understanding of pointers, pointer arithmetics, relations between pointers and arrays, syntax p[n] where p is a pointer. Actually it is C stuff, not specific to C++, but still a lot of people are uncomfortable with it to substantial extent.

- pointers to pointers (also a C stuff). For example, how to write a list (in C) minimizing special case processing of a first record / root pointer. Answer - to use pointer to the root pointer or a pointer 'next', instead of a pointer to a record.

- temporaries (expressions, values returned by functions), where they live, and how long they live. Special case - how long lives a temporary assigned to a const reference.

- references and their relation to pointers (in substance, a C++ reference is almost the same thing as a const pointer with a different syntax - but not just a pointer, nor a pointer to const)

- const in different settings:

-- const integers (char, int, long)
-- const pointers - and pointers to const - and const pointers to const
-- const in function (methods) parameters
-- const methods (const relatively a hidden paramter - an instance of a class that owns the method)
-- const-like attributes: volatile and mutable
-- const references and relations to temporaries (the question concerns const, temporaries, and references together, see above)

- order of evaluation of terms in expressions, function parameters : in many cases the order is not standardized in C++, that may cause a portability problem, even to a next version of the same compiler or between a debug and optimized builds.

- how a function return it value (two different ways are permitted by standard, that imposes semantic requirements on copy constructor)

Caution: There are very tricky aspects, related to a return of a std::auto_ptr or, even worse, of a class that contains std::auto_ptr. Hopefully, your interviewer will not ask, because he does not know to handle it himself. Or, if he know how, he understands that it is not worthwhile in the first place - better to use a boost::shared_ptr instead.

The above would probably take one weekend; actually it may take an evening only to refresh if you used to know most of the stuff but did not code in C++ for several years

If you have one week:

- operators, like opreator += (C & left, const C & right)

- classes and structures
- any class, even an empty class, i.e a class without data members, takes at least 1 byte of memory (sizeof > 0)
- inheritance, virtual methods, vtable, abstract classes, pure virtual classes
- upcast and downcast; static and dynamic casts, RTTI, typeid, typeinfo. Particularly, when dynamic cast throws and when returns NULL. And that the technique is inapplicable to classes that do not have virtual methods
- public/private/protected (particularly protected)
- friends (very rarely used, but often asked on interviews)
- operators as member of classes, e.g. operator += (const C & right)
- type conversions via a constructor with one argument ("import") or via operator ("export"). Keyword explicit. Tricky question - why copy constructor should not be explicit.
- implicit calls to copy constructors, particularly when passing arguments to function by value, or returning a function value.
- four things that C++ generates automatically if you do not declare them in classes: default constructor, default destructor, copy constructor, and assignment operator.
- declared constructor (with any parameters) precludes an automatic generation of a default constructor
- initialization of class members and parent classes (not in a body of constructor); order of the initialization.
- virtual destructor and why destructor should be virtual. Or, even better, when it should be virtual, when it should not, and when it does not matter.


Multiple inheritances, particularly virtual inheritance, is a thorny subject. Many shops even prohibit multiple inheritances, or limit them to Java-style cases, requiring that all parents but one should be pure virtual. If you do not know them, it is fine - very probably the interviewer does not know them either, and any case it is very typical even for decent to good C++ programmers. If you know them well, it is fine too. The worst case is if you do not know that it is tricky.

- Operators new and delete; array versions; a difference between them and malloc/free
(it may be dangerous somewhat, because interviewers often do not know or did not think trough some fine points themselves in my experience. Also, interviewers like to ask questions how memory management libraries are implementing malloc/free - that is not a part of C++, or even of C).
- More advanced: a placement version of operator new

- STL: it is a very big topic.

Many programmers think that they know STL, while in reality they know how to write std::vector, std::string, std::list, and may be few more containers. STL is much bigger than containers; particularly, <algorithm> contains about 50 canned algorithms that work on pair of iterators. Most widely used of them are copy, transform, sort, and for_each; however, it always is worthwhile to scan a list of the algorithms before coding your own. You may find a little jewel like n-th element when you want to extract efficiently a median or other percentile, for example.

I would suggest to scan through STL algorithms while preparing to interview, and to learn only may be 5 of them. No time for more, and probably mo use either. Also, learn std::set, std::map, and other containers like priority queue. I would not expect questions about <functional> on interview; when coding <functional> was very useful, but boost provides better alternatives now.

Concerning maps: operator [] creates a new element of the map with the key and a default value, if the map did not contain such an element already. A corollary: operator [] is not const, (relative to the underlying map). Both limit severely the usage of the operator, particularly when a map is const. Method 'find' is used instead.

- exceptions

== I am afraid that it is too much already ==
 
Reply
   
Quote
   
Top
   
Bottom
     



kmg
Junior Member

Posts: 18
Joined: Dec 2006

Mon Jan 18, 10 12:38 AM
User is offline


Yurakm, thank you for your feedback. This is a great list. And corroborates some of my own thinking, while presenting some new areas. This is really very appreciated - seems like you really thought about it, too.

Quote

The above would probably take one weekend; actually it may take an evening only to refresh if you used to know most of the stuff but did not code in C++ for several years


This, by the way, is closest to my situation. It's a review after not having programmed for some years ... it's been coming back pretty readily, which feels good. [I'm using C++ Super Review which is really quite good imnsho. A very "immediate" read ... and author is careful to point out tricky aspects.] I'll go to secondary sources after getting through this text.

As I mentioned earlier, the semantics are quite familiar. I just want to do as much as I can to nail down syntax and the tricky bits. One doesn't get the opportunity to learn from programming and compiling in an interview / assessment.

kmg
 
Reply
   
Quote
   
Top
   
Bottom
     



lexington
Senior Member

Posts: 313
Joined: Nov 2008

Mon Jan 18, 10 03:25 AM
User is offline

Quote

Originally posted by: kmg
Hi forum-

I'm gearing up for an interview (C++). I would appreciate any suggestions on advanced topics to review and / or specific interview questions you've come across that you found advanced or tricky (and at least reasonably likely to reappear - i.e. a good interview question).

kmg

For advanced topics review as many items from

Herb Sutter's books
 
Reply
   
Quote
   
Top
   
Bottom
     



Cuchulainn
Senior Member

Posts: 37513
Joined: Jul 2004

Mon Jan 18, 10 07:37 AM
User is offline

Quote

Caution: There are very tricky aspects, related to a return of a std::auto_ptr or, even worse, of a class that contains std::auto_ptr. Hopefully, your interviewer will not ask, because he does not know to handle it himself. Or, if he know how, he understands that it is not worthwhile in the first place - better to use a boost::shared_ptr instead.



Or possibly boost::scoped_ptr since onwership is never transferred with this smart pointer.

Exception safety and smart pointers is important.

-------------------------
www.datasimfinancial.com

Edited: Mon Jan 18, 10 at 07:43 AM by Cuchulainn
 
Reply
   
Quote
   
Top
   
Bottom
     



ckarakus
Senior Member

Posts: 470
Joined: Oct 2004

Mon Jan 18, 10 10:09 AM
User is offline

My favorite interview question:

Design and implement an anagram generator. Your program will take a text file of English words as input and builds all the internal data structures etc and then for a given word it will list all the anagrams corresponding to that word in the dictionary

- Considering memory cheap these days, trade memory for speed
- First implement with just standard STL containers
- Then assume we can use some hash containers(hash_map)

This is definitely worth to implement

-------------------------
Implementation matters!
 
Reply
   
Quote
   
Top
   
Bottom
     



lexington
Senior Member

Posts: 313
Joined: Nov 2008

Mon Jan 18, 10 10:38 AM
User is offline

Quote

Originally posted by: ckarakus
My favorite interview question:


- Considering memory cheap these days, trade memory for speed
-
This is definitely worth to implement

Wrong idea. Main memory is cheap. Not cache memory.
 
Reply
   
Quote
   
Top
   
Bottom
     



Cuchulainn
Senior Member

Posts: 37513
Joined: Jul 2004

Mon Jan 18, 10 12:30 PM
User is offline

Quote

Originally posted by: ckarakus
My favorite interview question:

Design and implement an anagram generator. Your program will take a text file of English words as input and builds all the internal data structures etc and then for a given word it will list all the anagrams corresponding to that word in the dictionary

- Considering memory cheap these days, trade memory for speed
- First implement with just standard STL containers
- Then assume we can use some hash containers(hash_map)

This is definitely worth to implement


Quote

Madonna Louise Ciccone = Occasional nude income and "One cool dance musician"; William Shakespeare = I am a weakish speller, Roger Meddows-Taylor = Great words or melody.



What about talking about the algo first?

-------------------------
www.datasimfinancial.com
 
Reply
   
Quote
   
Top
   
Bottom
     



StatTrader
Member

Posts: 167
Joined: Jan 2007

Mon Jan 18, 10 01:13 PM
User is offline

Unless you've actually used (and I mean in a real project) multithreading, smart pointers, STL, and whatever other titbits you choose to memorize, you're not going to fool any interviewer worth his salt. It is *very* easy to distinguish between an hardcore developer and someone who has crammed C++ syntax for a couple of weeks. None of the stuff mentioned so far is advanced, its just bread and butter C++ in 2010.








 
Reply
   
Quote
   
Top
   
Bottom
     



kmg
Junior Member

Posts: 18
Joined: Dec 2006

Mon Jan 18, 10 02:08 PM
User is offline

Agreed, StatTrader. However, this interviewer sends out a web-based assessment prior to actually scheduling the interview. I'll have to get past this before moving forward. Apparently, scoring well goes over well with this group.

kmg
 
Reply
   
Quote
   
Top
   
Bottom
     



traderjoe1976
Senior Member

Posts: 1455
Joined: May 2006

Tue Jan 19, 10 09:38 PM
User is offline

You can use the following books for C++ programming.
The C++ Programming Language, Special Edition, by Bjarne Stroustrup
Introduction to C++ for Financial Engineers: An Object-Oriented Approach by Daniel J. Duffy
Financial Instrument Pricing Using C++ by Daniel J. Duffy

You probably also need to know OO (Rumbaugh), RDBMS, SQL.
Maybe even VBA for Excel.
 
Reply
   
Quote
   
Top
   
Bottom
     



siva9783
Junior Member

Posts: 2
Joined: Jan 2010

Fri Feb 26, 10 08:45 PM
User is offline

Hi KMG, did you finish the web based test. Could you give me some info about the difficulty level/topics of the test. I have one next week also with IKM. My experience is also very similar to yours in that I havent used C++ in a while.

Thanks for your info.
SP
 
Reply
   
Quote
   
Top
   
Bottom
     



kmg
Junior Member

Posts: 18
Joined: Dec 2006

Fri Feb 26, 10 11:15 PM
User is offline

@SP-

I did, yes. And I feel quite confident suggesting the following two texts:

1. C++ Super Review (REA). Some may balk at this - don't care. You can read that thing in a couple of days (in particular if you have good recall). It's prose is clear and it's a good solid review. If you're semantically comfortable for the most part.

But the above is (potentially) necessary, but (certainly) insufficient. Follow up with:

2. Effective C++ (Meyers). Again, the prose here is clear. But the knowledge depth is far greater - but of the level that I think a strong score requires. [And one probably couldn't read Meyers terribly effectively without a conceptual refresher anyhow.] People rave consistently about this text - look anywhere online. I have to join the choir - it seems quite well justified to me.

Unfortunately, a week is short. So, it's unlikely that you'll be able to ingest all of this material by then. In which case you'll have to make a choice, take the exam (with perhaps not quite the level of preparedness that you'd like, or backout - and find a way to get to do the assessment later.) I put it this way because I'm not terribly opposed to the latter. A weaker score is perhaps harder to recover from (with a given company / manager / group). Anyhow, a strategic consideration.

Suffice it to say, that the exam rewards timeliness and judgment, not just technically correct responses. A strong score that takes twice as long probably doesn't cut it with someone using this format. And dumb answers are similarly unforgivable - they show that you lack the required command of material for a given question (i.e. you're guessing -- bad). It's graded rather like a GRE or GMAT. If it thinks you suck, then it'll give you milk-toast questions... (not to incite trepidation - it's just how this thing works).

So, I'd say... that it's supremely important to know the language (for lack of a better expression) to a real, demonstrable level of depth. But cold. As in, the answers are "ready" in your mind. If you don't, it's perhaps not worth it. [Alternative attitude is to simply gain the experience of taking the assessment, but clearly that comes at a bit of a cost... ]

Oh, finally, you may get suggestions that STL is hugely important for an assessment like this. I don't personally believe so. Understanding the most common containers and the semantics / syntax of template programming and in particular STL seem to be the extent of the requirement as regards that area. Seems to me to be so much more important to really understand C++ deeply (excluding externally developed libraries intended to extend or augment the language's standard libraries).

KMG
 
Reply
   
Quote
   
Top
   
Bottom
     



twofish
Senior Member

Posts: 4926
Joined: Feb 2005

Sat Feb 27, 10 06:13 PM
User is offline

If you want to game the test, go to the C++Faq and learn as much obscure syntax as you can, and then go through Meyers and just memorize as many rules as you can. If it's a multiple choice test, most of it is going to be on obscure and useless bits of knowledge, so just cram as much obscure and useless bits of knowledge as you can.

The goal is to get your score high enough so that you get the face-to-face interview. Once you get the face to face interview, then the test is forgotten.

You need to understand what the purpose of the test is. Getting a really high score is useless, since getting a high score on these things just involves memorizing useless bits of trivia. The purpose of the test is to weed out anyone that has no chance of passing a face-to-face interview, and so your goal is not to get an ultra high score, but rather to avoid a low one. Cramming *probably* won't help you, but you have nothing much to lose, and if you can add a few points so that you turn a "don't bother interviewing" to a "well, it's low but it's *barely* enough so that we can interview" then it's worth it.

Just you are just trying to get over the hump. Memorize, don't try to understand, since understanding is not that useful for multiple choice tests. Now if you get over the hump and then get your a face to face interview *then* you need to go back and review Meyers so that you can start understanding some of the things that you didn't. In a face to face interview, don't try to pretend you are a guru, but just make sure that you have the basics down.

Also don't stop reading once you get the interview. If you don't get the interview, keep reading since it will help you for the next interview. If you *do* get the interview, and you *do* get the job, then still keep reading. I've been programming C++ for 20 years, and I'm still learning new stuff.

One final thing. Do not cram the night before the test. Get a good night's sleep and don't stress out. A good night's sleep and the ability to stay calm is going to help you a lot more than cramming.

-------------------------
Code Janitor
 
Reply
   
Quote
   
Top
   
Bottom
     

Pages: [ 1 2 >> Next ]
View thread in raw text format
FORUMS > Careers Forum < refresh >

Forum Navigation:

© All material, including contents and design, copyright Wilmott Electronic Media Limited - FuseTalk 4.01 © 1999-2014 FuseTalk Inc. Terms & Conditions