P
P
papa_justify2011-02-28 14:07:27
Programming
papa_justify, 2011-02-28 14:07:27

Interview questions for a C++ programmer

Advise interesting questions to a C ++ programmer to evaluate his knowledge?

Here are a few questions I ask during interviews:

1. Virtual functions - what is it and why?
2. Virtual destructor - what is it and why?
3. Which is preferable, inheritance or encapsulation? in what cases and why?
4. There are such magic words: mutex and volotile, what are we talking about?
5. How is a process different from a flow?

Answer the question

In order to leave comments, you need to log in

11 answer(s)
D
DeNnEr, 2011-02-28
@DeNnEr

Ask about the use of const in different parts of the function declaration.
Purely so, you can ask on the topic of what is faster in Unix: threads or processes. The question is a little controversial, but you can draw some conclusions.
Ask how a person feels about the preprocessor, give a couple of dangerous macros like a + b (after all, (a + b) will be correct), ask them to find a problem.
Yes, ask me to talk about ++, --, about the results of executing the code int i = 5; ++i + ++i;. The correct answer will be: as the compiler wants, what will be the phase of the moon, 13, 14.
Torment on templates, if the salary is from 60k, then he should know them well.
Ask about Boost, how he treats him, ask him not to dissemble (he will say something about 2-page errors - everything is ok).
Ask how he relates to Qt.
In general, there are so many traps in C ++ that it's terrible. Stroustrup describes quite a few of them, so you can take examples from there and give them. Even if a person remembers the answers, this will already mean that he has read Stroustrup and understood everything that is there, and this is a huge plus.

S
SkyKos, 2011-02-28
@SkyKos

You can add questions about standard containers. For example: how is erase() different from remove()?

F
Fanruten, 2011-02-28
@Fanruten

see the classics)
blog.gamedeff.com/?p=64

U
uglymeta, 2011-02-28
@uglymeta

Well, I would add the traditional question about the difference between ++i and i++, of course you can’t call it a question, but it will be interesting to see how the subject answers and reacts.

5
57DeD, 2011-02-28
@57DeD

Mono add a couple of questions about templates. For example, like this.
There is an announcement
templatevoid f( T arg )
{
printf( "general call" );
...
}
template<>
void f( long arg )
{
printf( "explicit call" );
...
}
и вызов
int i = 0;
f( i );

Что будет вызвано?
Вместо int и long можно использовать указатели на класс и его предок; константный и неконстантный указатели.

M
MikeMirzayanov, 2011-03-01
@MikeMirzayanov

Which is better, inheritance or encapsulation? in what cases and why?

Some strange question. Did you mean inheritance and delegation?

S
silvansky, 2011-07-05
@silvansky

I filled up several people with a stupid question - what is the difference between virtual functions and pure virtual.
You can also ask about mutable - few people know about this thing.
Well, even drive on stl, you need to know the basics! Like, what will cope with such and such a task faster: vector or map? Areas of applicability, etc.
"5. What is the difference between a process and a thread? - this is rather a question for general computer literacy, like “What is the difference between a processor and a system unit?”, which we were asked in computer science at school.

F
Fil, 2011-02-28
@Fil

Here (http://habrahabr.ru/blogs/cpp/75948/) is a link to 385 questions and a discussion.

S
sphaerion, 2011-02-28
@sphaerion

Something about exceptions. For example, what happens when an exception occurs in a constructor or destructor. Leaks and the like.

J
javenue, 2011-03-07
@javenue

I think the questions should be divided into groups. Here are some of them that seem important to me:
1. Syntax
2. OOP in C++ (OOP enablers).
3. Pointers and memory management
4. Exception handling
5. Libraries (STL, boost, QT - depending on what is required for the project)
6. Templates.
Here are some questions with answers - www.quizful.net/interview/cpp

K
kaapython, 2011-08-26
@kaapython

In my opinion, the most interesting questions are those that are as close to real life as possible. Those. You can, of course, ask about the behavior of constructions like i++ + ++i, but why?
Now to the questions themselves. Questions, of course, you can invent on your own, but the most reliable way is to take books by Scott Myers from the Effective use of C ++ series , of which, if my memory serves me, 3 pieces. Each chapter is essentially a question with a detailed explanation of the answer.
Are the questions only required for C++ or ANSI C as well? Despite the fact that most developers write C / C ++ in their resumes, they never know C themselves :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question