Reference Page: C-Language|C++|C#|VB.Net|Asp.Net

C++ Links : Learn     Interview Questions     Software IDE C++ Jobs : Indeed.com     ZipRecruiter.com     Monster.com

C++ Interview Questions - Page 5

< Previous Page              Next Page >
Question: What are the differences between 'std::function' and function pointers in C++?
Answer: The std::function is a polymorphic function wrapper provided by the C++ (Standard Library) that can hold any callable target, including function pointers, member function pointers, function objects, and lambdas.
Function pointers, on the other hand, can only point to regular functions.

Question: What is the role of the 'override' keyword in C++?
Answer: The 'override' keyword is used to explicitly declare that a member function overrides a virtual function from a base class. It helps improve code clarity and provides compile-time checks to ensure that the function signature matches that of the base class.

Question: Can you explain the concept of type erasure in C++ with an example?
Answer: Type erasure is a technique used to abstract away the specific type of objects by encapsulating them in a polymorphic wrapper. An example of type erasure in C++ is the use of 'std::function' to store callable objects of different types in a uniform way, enabling generic programming.

Question: What are the differences between 'std::mutex' and 'std::recursive_mutex' in C++?
Answer: Both std::mutex and std::recursive_mutex are used for providing exclusive access to shared resources in multithreaded environments, but the key difference is that std::mutex does not allow the same thread to lock it multiple times (non-recursive), whereas std::recursive_mutex allows the same thread to lock it recursively.

Question: What is the 'decltype' keyword in C++ and how is it used?
Answer: The 'decltype' keyword in C++ is used to obtain the declared type of an expression or variable. It is useful in scenarios where the type needs to be deduced from an expression without actually evaluating it, such as when declaring variables or specifying function return types.

Question: Can you explain the concept of CRTP (Curiously Recurring Template Pattern) in C++?
Answer: The CRTP is a design pattern in C++ where a class template inherits from a base class, and the base class is parameterized by the derived class itself.
It is commonly used to implement static polymorphism, where the derived class provides implementations for methods defined in the base class.

Question: What are the differences between 'std::forward_list' and 'std::list' in C++?
Answer: The std::forward_list is a singly linked list that only supports forward traversal and occupies less memory compared to std::list, which is a doubly linked list. However, std::list supports bidirectional traversal and provides constant-time insertion and deletion operations.

Question: What is the difference between 'std::tie' and 'std::tuple' in C++?
Answer: The std::tie is a function that creates a tuple of references to its arguments, allowing multiple return values to be unpacked easily.
While std::tuple is a class template that represents a fixed-size collection of heterogeneous values.

Question: Can you explain the concept of variadic templates in C++?
Answer: The 'Variadic templates' in C++ allow defining functions and class templates that take a variable number of arguments of different types. They are particularly useful for creating generic functions or classes that operate on an arbitrary number of arguments.


< Previous Page Next Page >