C++ Language
From Software Engineers Wiki
Contents |
Basic
- General QA
- How to mix C and C++ codes?
- C++ keywords
- Lifetime of Objects
- Can automatic variables have variable size?
- What are the different forms of initialization and what's the difference?
Types, Type casting
- What is the difference between uint16_t and uint_fast16_t?
- What is the difference between using and typedef?
- How to cast const type to non-const type?
Class
- What is the structure of vtable, and how an object finds its vtable?
- What is the structure of vtable when multiple inheritance is used?
- What is the structure of vtable when virtual multiple inheritance is used?
- What is ISA and HASA class relationship?
- What is abstract class?
- What is the result of sizeof() of an empty class?
- How to initialize static member of a class?
- How to define a pointer to a member variable?
- In constructor, are the members initialized in the initializer in certain order?
- How to suppress operations?
Constructor/Destructor
- When to use virtual destructor?
- Can a constructor call other peer constructor in the same class?
- What is default constructor?
- Can we call constructors and destructors explicitly?
- What is prototype of copy constructor, and why it passes reference?
- What's the order of creation of class and class member variables?
- Can constructors and destructors call virtual function?
Inheritance
- What's the order of constructors and destructors when a class is derived from a base class?
- What is virtual inheritance in C++?
- How constructors and destructors are called in case of multiple inheritance?
- How to resolve ambiguity in when same names exist in multiple inheritance?
- It is possible to inherit a class template?
Polymorphism
Exceptions
- How C++ exceptions work?
- What is the proper way to throw an exception and catch the exception?
- What happens if exceptions are not handled?
- How to catch all standard exception in single catch?
- Can a destructor throw an exception?
- Does C++ catch division by zero exception?
- What is the effect of -fno-exceptions compiler option?
- Is RTTI needed for exception handling?
- How G++ handles exceptions?
- Can we nest exceptions?
- Does exception handling increase code size?
- How to prevent new from throwing an exception?
- Can a constructor throw an exception?
Template
Namespace
Operator
- Overload ++ operator in prefix and postfix form
- What operators do not allow overloading?
- Is it possible to overload operators for built-in types such as int?
- When to use member or non-member operator overloading?
- Is there a performance difference between pre-increment and post-increment?
Smart Pointers
- Implement unique_ptr<T> template class.
- How the use count changes when shared_ptr<int> is created and assigned?
Memory
- How new is different from malloc()?
- Memory allocation by new
- Is it possible to hook new and delete and create custom memory manager?
- Overload new and delete an object of a class
I/O
C++11
- What is constexpr?
- What is enum class is how is it different from enumeration?
- What is static_assert() and how is it different from assert()?
- What is function object in C++?
- What is lambda expression?
- What is decltype() and what is the use of it?
- What is functional (std::function<>) and how is it used?
- Is there performance difference between function pointer and functional (std::function<>)?
- How a custom class can support range for (for (:))?
Programming Techniques
- Is it better to initialize member variable using the initializer list than doing it inside constructor?
- What is __static_initialization_and_destruction_0 function created by GCC compiler?
- Can we have an interface, and load different implementation of the interface without stopping an application?
- What is singleton and how to define singleton class?