1. What is a modifier?
A modifier, also called a modifying function is a member function that changes the value of at least one data member. In other words, an operation that modifies the state of an object. Modifiers are also known as ‘mutators’.
2. What is an accessor?
An accessor is a class operation that does not modify the state of an object. The accessor functions need to be declared as const operations
3. Differentiate between a template class and class template
A generic definition or a parameterized class not instantiated until the client provides the needed information. It’s jargon for plain templates.
A class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It’s jargon for plain classes
4. Define namespace.
It is a feature in c++ to minimize name collisions in the global name space. This namespace keyword assigns a distinct name to a library that allows other libraries to use the same identifier names without creating any name collisions. Furthermore, the compiler uses the namespace signature for differentiating the definitions
5. What is the use of ‘using’ declaration.
A using declaration makes it possible to use a name from a namespace without the scope operator.
6. What is an Iterator class?
A class that is used to traverse through the objects maintained by a container class. There are five categories of iterators:
7. Differentiate between the message and method.
Objects communicate by sending messages Provides response to a message.
to each other.
A message is sent to invoke a method. It is an implementation of an operation.
8. What is an adaptor class or Wrapper class?
A class that has no functionality of its own. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non- object- oriented implementation.
9. What is a Null object?
It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.
10. Name some pure object oriented languages.
11. Name the operators that cannot be overloaded.
sizeof . .* .-> :: ?:
12. What is a concrete class?
A concrete class is used to define a useful object that can be instantiated as an automatic variable on the program stack. The implementation of a concrete class is defined. The concrete class is not intended to be a base class and no attempt to minimize dependency on other classes in the implementation or behavior of the class.
13. What is cloning?
An object can carry out copying in two ways i.e. it can set itself to be a copy of another object, or it can return a copy of itself. The latter process is called cloning.
14. Describe the main characteristics of static functions
The main characteristics of static functions include,
It is without the a this pointer,
It can't directly access the non-static members of its class
It can't be declared const, volatile or virtual.
It doesn't need to be invoked through an object of its class, although for convenience, it may.
15. Will the inline function be compiled as the inline function always? Justify.
An inline function is a request and not a command. Hence it won't be compiled as an inline function always.
16. Define a way other than using the keyword inline to make a function inline.
The function must be defined inside the class.
17.Can we declare a static function as virtual?
No. The virtual function mechanism is used on the specific object that determines which virtual function to call. Since the static functions are not any way related to objects, they cannot be declared as virtual.
18.How do I refer to a name of class or function that is defined within a namespace?
There are two ways in which we can refer to a name of class or function that is defined within a namespace: Using scope resolution operator through the using keyword.
19.While overloading a binary operator can we provide default values?
No!. This is because even if we provide the default arguments to the parameters of the overloaded operator function we would end up using the binary operator incorrectly.
20.How do I carry out conversion of one object of user-defined type to another?
To perform conversion from one user-defined type to another we need to provide conversion function.
21.What are manipulators?
Manipulators are the instructions to the output stream to modify the output in various ways. The manipulators provide a clean and easy way for formatted output in comparison to the formatting flags of the ios class. When manipulators are used, the formatting instructions are inserted directly into the stream. Manipulators are of two types, those that take an argument and those that don’t
22.What are put and get pointers?
These are the long integers associated with the streams. The value present in the put pointer specifies the byte number in the file from where next write would take place in the file. The get pointer specifies the byte number in the file from where the next reading should take place.
23.What is the purpose of istream class?
The istream class performs activities specific to input. It is derived from the ios class. The most commonly used member function of this class is the overloaded >> operator which can extract values of all basic types. We can extract even a string using this operator.
24.Can we use this pointer inside static member function?
No! The this pointer cannot be used inside a static member function. This is because a static member function is never called through an object.
25.Can I have a reference as a data member of a class? If yes, then how do I initialise it?
Yes, we can have a reference as a data member of a class. A reference as a data member of a class is initialised in the initialisation list of the constructor.
26.What is forward referencing and when should it be used?
Forward referencing is generally required when we make a class or a function as a friend.
27.How would you give an alternate name to a namespace?
An alternate name given to namespace is called a namespace-alias. namespace-alias is generally used to save the typing effort when the names of namespaces are very long or complex. The following syntax is used to give an alias to a namespace.
namespace myname = my_old_very_long_name ;
28.Why is it necessary to use a reference in the argument to the copy constructor?
If we pass the copy constructor the argument by value, its copy would get constructed using the copy constructor. This means the copy constructor would call itself to make this copy. This process would go on and on until the compiler runs out of memory.
29.Can we allocate memory dynamically for a reference?
No! It is not possible to allocate memory dynamically for a reference. This is because, when we create a reference, it gets tied with some variable of its type. Now, if we try to allocate memory dynamically for a reference, it is not possible to mention that to which variable the reference would get tied.
30.When should I overload new operator on a global basis or a class basis?
We overload operator new in our program, when we want to initialize a data item or a class object at the same place where it has been allocated memory.
31.What is RTTI?
RTTI stands for 'Run Time Type Information'. We use virtual function mechanism where we can call derived class's member functions using base class's pointer. However, many times we wish to know the exact type of the object. We can know the type of the object using RTTI. A function that returns the type of the object is known as RTTI functions. C++ supports two ways to obtain information about the object's class at run time, they are typeid( ) operator and dynamic_cast operator.
32.What is the disadvantage of a template function?
A template function cannot be distributed in the obj form. This is because, with which parameters the template function is going to be called is decided at the run time only. Therefore an obj form of a template function cannot be made by merely compiling it.
33.How to restrict a friend class's access to the private data members?
If we declare a class as a friend of our class the friend class can access the private data members of our class. However, if we want we can restrict this access to some selective functions of the class.
34.How would you call a C function from C++ code?
Using extern "C".
The function prototype must be preceded by extern "C".
35.What is Early Binding and Dynamic Binding?
The term binding refers to the connection between a function call and the actual code executed as a result of the call. Early Binding: If which function is to be called is known at the compile-time it is known as static or early binding. Dynamic Binding: If which function is to be called is decided at run time it is called as late or dynamic binding. Dynamic binding is so called because the actual function called at run-time depends on the contents of the pointer. For example, call to virtual functions, call to functions to be linked from dlls use late binding.