Niroshan Rajadurai

  • Increase font size
  • Default font size
  • Decrease font size

C++ Technical Questions

E-mail Print PDF
User Rating: / 0
PoorBest 

1) Discuss (In depth) on const keyword in C++, like the behaviour it exhibits when used on primitive data types, objects, pointers.

 

  • What are pointers to constants (const char *p, char const *p) and constant pointers (char *const p) Explain const on member functions of a class.
  • How can I change a data member in const member function?(mutable).
  • Why would I want to do that? (One instance is, to do the lazy initialization on a datamember if that variable is a pointer and being used withn const member function)

 

2) What are static members?

 

  • Howare static member functions different to this?
  • Can I call a non static member within static member functions?(No)
  • What are static data members?
  • Can I control the order of static member initialization?(No)

 

3) What are exceptions?

 

  • What happens when I throw an exception from constructor and destructor. Explain the implications with examples.
  • What are exception safety rules.
  • What happens when a call to new fails while creating memory on the heap.(bad_alloc exception)

 

4) What are different mechanisms of type casting?

 

  • Inparticular discuss the difference between static_cast and dynamic_cast.
  • What happens when a dynamic_cast fails? (throw an exception bad_cast or return null?)

 

5) What is polymorphism? (check understanding of dynamic binding, virtual functions)

 

  • Why would I need a virtual destructor?
  • In case I am writing a base class, when would I use pure virtual functions? (Interface definition)
  • While writing the base class why shouldn't I make the destructor always virtual?

 

6) What are smart ptrs?

 

  • explain what Auto ptrs and shared ptrs are.
  • What are the issues concerned with auto ptrs and shared ptrs.

 

7) What are STL containers?

 

  • Elaborate on the factors to choose the right type of container for requirment?
  • Can I use auto pointers within containers?
  • What is the complexity of inserting into a list(O(1), as it is implemented using doubly link list)?
  • What is worst case complexity of searching an element in a unsorted vector (O(N))and a sorted vector(O(LogN) as it employs binary search)?

 

8) What is multi threading?

 

  • Explain the deadlock scenario and how can I resolve this issue. (Elaborate in detail)

 

9) What is the difference between a Copy constructors and Assignment operators.

 

  • When is it appropriate and not appropriate to use these operators

 

10) Give an instance where Member-wise initialisation is useful

11) Qhat is the difference between a Struct and a Class?

 

  • Can you inherit from a Struct?

 

12) RTTI – Dynamic Cast – what is it what are the return types?

13) Which design patterns have you used in the past ?

 

  • Can you explain what it is?
  • Would this pattern require any additional considerations when used in a multi-threaded environment?

 

14) What STL container have you used?

 

  • What influenced your decision to use them?
  • What are the performance characteristics of these STL containers? (Big 'O' notation is sufficient)

 

15) Exception handling – what is it?

 

  • If you are unable to trap an exception at a particular level what of you do (throw)

 

16) Deadlocking what is it and give an example of how you can design your code to overcome it ?

17) Post Increment V pre increment which is more efficient and why.

18) What is the last good c++ book that you read?

19) If you create memory on the heap within a function and you unexpectedly return from that function how do you ensure that that memory is deleted?

20) How do you make a const function have non – const ability?

21) What's a race condition?

22) What's an associative container in STL?

23) What's object slicing?

24) What is the benefit of object oriented programming?

25) What is generic feature of a class used in map? are there any limitation on it?

26) Copy constructor, what is it?

 

  • Deep copy,
  • Shallow copy
  • How do you prevent a class from being copied

 

27) What does the 'explicit' modifier mean?

28) Initialization lists, purpose, advantage over using the constructor body

29) Dynamic casts

 

  • Possible data types
  • What does the cast return
  • Can you cast generic data types
  • Can you cast references
  • What happens if reference cast is illegal
  • Internals about dynamic casts: given as cast with base and derived class, how is it internally determined, if the cast is correct.
  • Performance issues with dynamic casts
  • What happens, if you have many of them?
  • Why do we need them anyway

 

30) What is Polymorphism?

31) What are Design patterns?

 

  • Name some and describe briefly

 

32) Multi-threading: what is it?

 

  • Define deadlock, and how to prevent them.

 

33) Name container classes in STL

 

  • What are the run time complexity classes for those containers?
  • What internal search structure is used for stl map? (red-black trees)

 

34) What is a hash table?

 

  • What is it?
  • Complexity class
  • What is a collision?
  • What is the search complexity, if you have maximum number of collisions?

 

35) boost: what libraries have you used in the past

 

  • Have you used smart pointers

 

36) Which C++ books have you read to prepare yourself

 

  • Wuestions about the content of the book (it's not enough that you just name them, you should have read them too!!!)

 

37) What C++ constructs that support OO?

38) What do you need a virtual destructor in a base class

39) What mechanism in C++ allows the right method in a derived class to be called?

40) What does new return if it fails?

41) What methods does a compiler automatically create for you if you write an empty class?

42) What is encapsulation?

Comments (0)
Last Updated on Monday, 24 January 2011 12:27