Popular Questions from IT interviews on the C ++ language

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest

We have collected the most tricky questions from IT interviews on C ++, which are not just desirable, but you need to know the answers.

Often employers try to mislead us with complex questions and logical tasks. This is a kind of brainstorming session to test a candidate not only on the ability to correctly solve complex problems but also on the time for which he comes to the right answers.

In order not to hit the face in the dirt, look through our selection of hard questions from the IT interviews on C ++: it will definitely come in handy.

What does the modifier virtual mean?

In C ++, virtual functions allow supporting polymorphism – one of the critical components of OOP. Using it in child classes, you can override the functions of the parent class. Without a virtual function, we get “early binding”, and with it – “late binding”. That is, which implementation of the method is used, is determined directly at runtime and is based on the type of object with a pointer to the object from which it is built.

Is there a difference between a class and a structure?

The only difference between a class and a structure is access modifiers. The structure elements are public by default, and the class is private. It is recommended that you use classes when you need an object with methods, and in the case of a simple object, structures.

What is a storage class?

A class that defines the lifetime, layout, and location of variables/functions in memory.

In C ++, storage classes are supported: auto, static, register, extern, and mutable.

Note that register is deprecated for C ++ 11. For C ++ 17, it was removed and reserved for future use.

What does the keyword const do?

It specifies the constancy of the object, the pointer, and also indicates that this method preserves the state of the object (does not modify the members of the class).

Virtual constructor: what is it?

A tricky question from IT-interviews, which are often asked after virtual destructors, in order to confuse the candidate. The constructor cannot be virtual, because it does not make any sense: when creating objects, there is no ambiguity, as when they are deleted.

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp
Share on email

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recommended for you
Connect With Us
Stay Connected
Subscribe to our newsletter today to receive updates on latest tech news, tutorials SEO tips many more.
Latest Articles