manjunath


{ City } coimbatore
< Country > india
* Profession * executive faculty
User No # 14116
Total Questions Posted # 0
Total Answers Posted # 7

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

Users Marked my Answers as Correct # 294
Users Marked my Answers as Wrong # 110
Questions / { manjunath }
Questions Answers Category Views Company eMail




Answers / { manjunath }

Question { Accenture, 30617 }

Which is the parameter that is added to every non-static
member function when it is called?


Answer

Ex:

class Employee{
public:
int member_Function1(){}
void display()
{
do something;
}
};
int main()
{
Employee e1;
e1.member_Functiuon(int a, int b);------> refer below
1...
}

1...

Here e1 is an object of Employee Class.
Now e1.member_Function(int a, int b) means
implicitly the this pointer is applied to the
function as

member_Function(Employee *const this, int a, int b).

Here the implicit this is a constant pointer to the
object's address of type Employee. Once the Object has been
created the address is given to it(e1). the address is
passed as the first argument becoz the function resolving
is faster...

Is This Answer Correct ?    12 Yes 1 No

Question { Wipro, 48061 }

Can we have a private constructor ?


Answer

#include
using namespace std;
class A
{
int value;
A* ptr;
A()
{
cout<<"\n\t\tConctructor\n";
}
public:
static A* CreateObject()
{
A* ptr=NULL;
ptr=new A;
return ptr;
}

void getdata()
{
cout<<"\n\tEnter the Value of A class\t:\t";
cin>>value;
}
void putdata()
{
cout<<"\n\t\tThe Value of A Class\t:\t";
cout< }
~A()
{
cout<<"\n\t\tDestructor\n";
}
};
int main()
{
A *ptr,*ptr1,*ptr3;
ptr=A::CreateObject();
ptr1=A::CreateObject();
ptr3=A::CreateObject();
ptr->getdata();
ptr1->getdata();
ptr3->getdata();
ptr->putdata();
ptr1->putdata();
ptr3->putdata();
delete ptr;
delete ptr1;
delete ptr3;
return 0;
}


Ref:
Singleton and Factory
Classes...

Is This Answer Correct ?    3 Yes 5 No


Question { Wipro, 48061 }

Can we have a private constructor ?


Answer

Used mainly to control the object creation...
Ex: the Number of user Login's we can restrict to 15 by
creating 15 objects...

Is This Answer Correct ?    9 Yes 4 No

Question { 9436 }

WHY FUCTION OVERLOADING DOSENOT RETURN A RETEN TYPE


Answer

Function overloading has a return type...

Ex:
#include
using namespace std;
//Function 1:

int max(int a, int b)
{
return (a>b)? a:b;
}

//Function 2:

float max(float a, float b)
{
return(a>b)? a:b;
}

int main()
{
int c;
float d;
c=max(5,4); //will display 5
cout< d=max(3.14,6.15); //will display 6.15
cout< return 0;
}

Important Concepts in Fn. Overloading:
a) Fun Overloading depends upon the type/number/order in
which the arguments are passed...
b) Fun Overloading can take place for a function which is
within the same scope... (i.e.) both function 1:, and
Function 2: should be in the same { ...} (both the
functions are within main() (i.e. same scope)...

Is This Answer Correct ?    5 Yes 4 No

Question { 18586 }

what is abstract class ?
when is used in real time ?
give a exp


Answer

An Abstract Class is one in which the member function(s) at
the Base(Parent) Class are left undefined, but declared.
It's upto the Derived(child(ren)) Classes to Implement the
Functions declared in Base...


Ex:

Let us assume... As a father(Base Class), he has some Land
(Member Function), and he has not done any cultivation
(implementation) in it... As his Child(Derived Class), he
takes the Land(Member Function) from the Father(Base) and
does Agriculture(implementing the M.F. of Parent Class) in
the Child...

Concept of Inheritance...

Is it good enough!!!

Is This Answer Correct ?    30 Yes 18 No

Question { IBM, 38880 }

write a c++ program to find maximum of two numbers using
inline functions.


Answer

#include
using namespace std;
int main()
{
int c;
c=max(5,4); //will display 5
cout< return 0;
}
inline int max(int a, int b)
{
return (a>b)? a:b;
}

Is This Answer Correct ?    140 Yes 52 No

Question { 21033 }

What is the difference between const int *ptr and int const
*ptr???


Answer

a) const int *ptr and
b) int const *ptr


Both actually mean the same...

Read from Right to left:
for(a):-> ptr is a pointer to an integer Constant and
for(b):-> ptr is a pointer to a constant integer...

..............
int *const ptr----------> ptr is a constant pointer to an
integer...

Is This Answer Correct ?    95 Yes 26 No