madhukar


{ City }
< Country > india
* Profession *
User No # 74454
Total Questions Posted # 0
Total Answers Posted # 6

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 75
Users Marked my Answers as Wrong # 9
Questions / { madhukar }
Questions Answers Category Views Company eMail




Answers / { madhukar }

Question { 14365 }

What do you mean by pure virtual functions?


Answer

A pure virtual function tells the compiler that only
declaration is done here and it guarantees that function
definition will be done in the immediate class where object
is created.
It tells the user what it intended to do and without giving
complete details. And the pure virtual function will not
allow the user to create object and leads to abstract class.

Is This Answer Correct ?    3 Yes 0 No

Question { IBM, 25839 }

We have a scale and 7 balls. 1 ball is heavier than all the
rest. How to determine the heaviest ball with only 3
possible weighing attempts?


Answer

divide balls as 3 + 3 + 1 and
1. weight them 3 balls and 3 balls if both are equal the
outer ball is bigger one. else
2. Add the single ball which is not weighted before to the
higher weight 3 balls and now it total balls will be 3+ 1
and divide them as 2 + 2
3. In second attempt weight them and find which is having
higher weight then take the higher weight group and in 3rd
attempt compare them individual and you will get the bigger
ball in three attempts.

Is This Answer Correct ?    11 Yes 4 No


Question { Wipro, 26281 }

what is the function of 'this' operator ?


Answer

'this' pointer is created when you create an object with
dynamic memory allocation. 'this' pointer will be created at
the time of object creation.
It holds the current object's address.
'this' cannot be used inside the static or a friend functions.

Is This Answer Correct ?    14 Yes 2 No

Question { Siemens, 7098 }

tell about copy constructor


Answer

Basic thing, copy constructor will be called whenever a copy
is made. and copy constructors are called when:
1. create a new object using existing object.
2. When is returning to caller.
3. When an object is passed by value as a parameter to a
function

Basically a default copy constructor will be created which
does bitwise copy also know as shallow copy.
This will become a problem when we are dealing with dynamic
memory allocation for variables and leads to dangling pointer.
To overcome we have to override by deep copy.

Is This Answer Correct ?    3 Yes 0 No

Question { Ness Technologies, 27417 }

Differences between inline functions and non-inline functions?


Answer

Actually inline functions are used to overcome the demerits
of preprocessor macros and non-inline functions.
Whenever a function call is made function address, formal
arguments and return address will be stored in the stack.
Which leads the overhead to the compiler. To overcome this
inline functions are introduced.

Inline functions are the requester to the compiler to
replace the function definition at the function callers.
Here it is same as preprocessor macros but not equal to 100%
to macros.
The decision of implementing inline is done by compiler.
Points to be consider b/w inline && non-inline functions:
1. inline executes faster than non-inline functions.
2. Using inline will increase the code size than the
non-inline functions.
3. inline are ignored if the function definition contains
more code or loops or conditions.
4. if you define a function inside the class by default it
will treat it as a inline.

Is This Answer Correct ?    34 Yes 3 No

Question { 5277 }

what do you mean by static member variable?


Answer

In C++ when you declare and define a static variable, it
tells the compiler that only one copy of memory will be
allocated and all the objects of that class will share that
copy.
As we know for class data variables memory will be created
independently for every object of that class. and we can
access the data using object. But, for static variables
memory is created only once for all objects and is no object
is owned the static variable. we can access the static
variable using class name.

Mainly static variables are used when want to count the
objects created and destroyed and when we are dealing with
singleton design pattern.

Is This Answer Correct ?    10 Yes 0 No