Differentiate between declaration and
definition in C++.
A declaration introduces a name into the program; a definition provides a unique
description of an entity (e.g. type, instance, and function). Declarations can
be repeated in a given scope, it introduces a name in a given scope. There must
be exactly one definition of every object, function or class used in a C++
program.
A declaration is a definition unless:
Ø it declares a function without specifying its body,
Ø it contains an extern specifier and no initializer or function body,
Ø it is the declaration of a static class data member without a class
definition,
Ø it is a class name definition,
Ø it is a typedef declaration.
A definition
is a declaration unless:
Ø it defines a static class data member,
Ø it defines a non-inline member function.
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.
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.
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.
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.
Define a way other than using the keyword
inline to make a function inline.
The function must be defined inside the class.
How can a '::' operator be used as unary
operator?
The scope operator can be used to refer to members of the global namespace.
Because the global namespace doesn’t have a name, the notation :: member-name
refers to a member of the global namespace. This can be useful for referring to
members of global namespace whose names have been hidden by names declared in
nested local scope. Unless we specify to the compiler in which namespace to
search for a declaration, the compiler simple searches the current scope, and
any scopes in which the current scope is nested, to find the declaration for the
name.
What is placement new?
When you want to call a constructor directly, you use the placement new.
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 version
placement new allows you to do it.
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 applications using shared
memory or memory-mapped I/O, because objects in such applications must be placed
at specific addresses or in memory allocated by special routines.
OOAD
What do you mean by analysis and design?
Analysis:
Basically, it is the process of determining what needs to be done before how it
should be done. In order to accomplish this, the developer refers the existing
systems and documents. So, simply it is an art of discovery.
Design:
It is the process of adopting/choosing the one among the many, which best
accomplishes the users needs. So, simply, it is compromising mechanism.
What are the steps involved
in designing?
Before getting into the design the designer should go through the SRS prepared
by the System Analyst.
The main
tasks of design are Architectural Design and Detailed Design.
In
Architectural Design we find what are the main modules in the problem domain.
In Detailed Design we find what should be done within each module.
What are the main underlying
concepts of object orientation?
Objects, messages, class, inheritance and polymorphism are the main concepts of
object orientation.
What do u meant by "SBI" of
an object?
SBI stands for State, Behavior and Identity. Since every object has the above
three.
Ø State:
It is just a value to the attribute of an object at a particular time.
Ø Behaviour:
It describes the actions and their reactions of that object.
Ø Identity:
An object has an identity that characterizes its own existence. The identity
makes it possible to distinguish any object in an unambiguous way, and
independently from its state.
Page Numbers :
1
2
3
4
5
6
7 8
9