Technical Interview Questions and Answers :: C++
11 / 187
A predicate is a function object (or a function) that returns a bool.
12 / 187
An object of a class with an application operator is called a function. Like object, a function or simply functions object. Consequently, function objects often execute faster than do ordinary function.
(or)
An object that acts like a function is often called function like object (or) simply function. Such function objects are important because they allow us to write code that takes operations as parameters.
13 / 187
When dealing with numeric classes, it sometimes useful to have the arithmetic function available as function objects. Consequently the standard library provides arithmetic operations.
minus binary arg1 - arg2
multiplies binary arg1 * arg2
divides binary arg1 / arg2
modules binary arg1 % arg2
negate Unary -arg1
14 / 187
These algorithms are provided to do the most common forms of updates. Some update a sequence while others produce a new sequence based on information found during a traversal.
Std. algorithm work on data structures thru Iterators. This implies that inserting a new element into a container (or) deleting one is not easy.
15 / 187
A binder allows a two-argument function object to be used as a single-argument function by binding one argument is a value.
16 / 187
A member function adapter allows a member function to be used as an argument to algorithms.
A pointer to function adapter allows a pointer to function to be used as an argument to the algorithm.
17 / 187
Classes such as vector, list, date and complex are concrete in the sense that each is the representation of a relatively simple concept with all the operations essential for the support of that concept.
Each has a one to one correspondence between its interface and an implementation and none are intended as a base for derivation.
18 / 187
The aims of concrete type classes are:
i. To be a close match to a particular concept and implementation strategy.
ii. To provide run-time and space efficiency comparable to handcrafted code through the use of in-lining and of operations taking full advantage of the properties of the concept and its implementation.
iii. To have only minimal dependency on other classes; and
iv. To be comprehensible and usable in isolation.
v. Providing a clear and efficient representation of a single concept.
19 / 187
i. Concrete types are fitted into a hierarchy of related classes.
ii. Each concrete type can be understood in isolation with minimal reference to other classes.
iii. If a concrete type is implemented well, programs using it are comparable in size and speed to programs a user would write using a hand-crafted and specialized version of the concept.
iv. If the implementation changes significantly the interface is usually modified to reflect the change.
v. Concrete type resembles in the built in type.
20 / 187
i. An individual concrete classes are easier to understand and use then is a more general class.
ii. Concrete type is often used for classes that represent well-known data types such as arrays and list.