Answer:: 1. What Is A Modifier?
Answer:: 1. What Is A Modifier?
Answer:: 1. What Is A Modifier?
Answer:
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?
Answer:
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
5. Define namespace.
Answer:
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.
6. What is the use of ‘using’ declaration.
Answer:
A using declaration makes it possible to use a name from a namespace
without the scope operator.
In this example, cont_iter is the name of the iterator. It is created on the first
line by instantiation of cont_iterator class, an iterator class defined to iterate over
some container class, cont. Succesive elements from the container are carried to x.
The loop terminates when x is bound to some empty value. (Here, none)In the
middle of the loop, there is s(x) an operation on x, the current element from the
container. The next element of the container is obtained at the bottom of the loop.
9. List out some of the OODBMS available.
Answer:
Ø GEMSTONE/OPAL of Gemstone systems.
Ø ONTOS of Ontos.
Ø Objectivity of Objectivity inc.
Ø Versant of Versant object technology.
Ø Object store of Object Design.
Ø ARDENT of ARDENT software.
Ø POET of POET software.
Post-condition:
A post-condition is a condition that must be true on exit from a member
function if the precondition was valid on entry to that function. A class is
implemented correctly if post-conditions are never false.
For example, after pushing an element on the stack, we know that
isempty() must necessarily hold. This is a post-condition of the push operation.
19. What are the conditions that have to be met for a condition to be an
Answer:
Ø The condition should hold at the end of every constructor.
Ø The condition should hold at the end of every mutator(non-const) operation.
Answer:
Objects that stand for other objects are called proxy objects or surrogates.
Example:
template<class T>
class Array2D
{
public:
class Array1D
{
public:
T& operator[] (int index);
const T& operator[] (int index) const;
...
};
Array1D operator[] (int index);
const Array1D operator[] (int index) const;
...
};
Answer:
Ø Smalltalk,
Ø Java,
Ø Eiffel,
Ø Sather.
Answer:
sizeof . .* .-> :: ?:
that two classes operate in different dimensions and do not interfere with each
other in any way. The same derived class may inherit such classes with no
difficulty.
25. What is a container class? What are the types of container classes?
Answer:
A container class is a class that is used to hold objects in memory or
external storage. A container class acts as a generic holder. A container class has
a predefined behavior and a well-known interface. A container class is a
supporting class whose purpose is to hide the topology used for maintaining the
list of objects in memory. When a container class contains a group of mixed
objects, the container is called a heterogeneous container; when the container is
holding a group of objects that are all the same, the container is called a
homogeneous container.
function.
class Action
{
public:
virtual int do_it( int )=0;
virtual ~Action( );
}
Given this, we can write code say a member that can store actions for later
the objects involved, and without even knowing the name of the operation it
A user of the Action class will be completely isolated from any knowledge of
31. When can you tell that a memory leak will occur?
Answer:
A memory leak occurs when a program loses the ability to free a block of
dynamically allocated memory.
X& operator *( );
const X& operator*( ) const;
X* operator->() const;
function in your program a unique name. In C++, all programs have at-least a
few functions with the same name. Name mangling is a concession to the fact
Example:
In general, member names are made unique by concatenating the name of
the member with that of the class e.g. given the declaration:
class Bar
{
public:
int ival;
...
};
ival becomes something like:
// a possible member name mangling
ival__3Bar
Consider this derivation:
class Foo : public Bar
{
public:
int ival;
...
}
The internal representation of a Foo object is the concatenation of its base and
extensive mangling to provide each with a unique name. Here the compiler
generates the same name for the two overloaded instances(Their argument
scope. There must be exactly one definition of every object, function or class
copy of another object, or it can return a copy of itself. The latter process is called
cloning.
43. Will the inline function be compiled as the inline function always? Justify.
Answer:
An inline function is a request and not a command. Hence it won't be
compiled as an inline function always.
Explanation:
Inline-expansion could fail if the inline function contains loops, the
address of an inline function is used, or an inline function is called in a complex
expression. The rules for inlining are compiler dependent.
44. Define a way other than using the keyword inline to make a function
inline.
Answer:
The function must be defined inside the class.
Sometimes you have some raw memory that's already been allocated, and you
need to construct an object in the memory you have. Operator new's special
class Widget
{
public :
Widget(int widgetsize);
...
Widget* Construct_widget_int_buffer(void *buffer,int widgetsize)
{
return new(buffer) Widget(widgetsize);
}
};
This function returns a pointer to a Widget object that's constructed within
the buffer passed to the function. Such a function might be useful for
special routines.