ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories >> Software >> Programming-Languages >> C++
 
  STL (44)  OOPS (185)  C++-General (218)
 


 

Back to Questions Page
 
Question
Name an advantage of linked list over array?
Rank Answer Posted By  
 Question Submitted By :: Kunal
This Interview Question Asked @   IBM
I also faced this Question!!   © ALL Interview .com
Answer
1. Array size is fix and cannot change at run time,But in 
link list we can create memory accoring to requirement.
2. In array we define but at the run time it is not used so 
in that case memory is waste.
 
0
Manoj Kumar Jha
 
 
Answer
array always contain static memory location even linklist 
contain dynamic memory location.In once declaration of an 
array we can store smae type of data but in linkedlist 
hetrogeneous link list is possible which can be contain 
diffrent diffrent types of data type in linkedlist.in link 
list we are using void pointer.
 
0
Ritesh Parkhi
 
 
Answer
Array is of fix size & contain always same type of data.

Whereas linklist is dynamic in size.And a type of linklist 
have capability to store different type of data at its 
nodes, and for doing that we use void pointer( a pointer 
that can point any type of data )
 
0
Azhar Iqbal
 
 
 
Answer
double dimension array
 
0
Varsha Vilas Kalebag
 
 
Answer
In array we can directly access any element by index number 
but in Linked list it is not possible,in linked list if we 
want to access any element then we go from starting node.
 
0
Amandeep Singh Bhatia
 
 
Answer
in array we can
 
5
Amar Muduli
 
 
Question
What is a linked list? 
Rank Answer Posted By  
 Question Submitted By :: Kunal
This Interview Question Asked @   IBM , Nural Info Solution
I also faced this Question!!   © ALL Interview .com
Answer
Link list is a collection of either diffrent diffrent data 
or same type of data which is store in a node,basically 
node contain  non premitive data witch is divided into two 
parts one part contain data and another part contain 
address of next node..
 
0
E-mail
 
 
Answer
link list is a list that is used to sort by the names
 
0
Venu
 
 
Answer
" Linked List is a collection of data elements consisting 
of nodes", basically two parts:-
1. INFO part- contains the information/value of data items.
2.LINK part- keeps the address of the adjacent node,i.e, 
  co-relating notes.

The basic application,i.e, the linear arrangement of data 
items gives the fundamental idea of array.
 
0
Purba Phalguni Mishra
 
 
Answer
Linked list is a datastructure which consist of many nodes 
linked wit each other.Each node is divided in to  
2parts.one has the data and the other has address which 
points to the next node.the last node has null pointer.
 
0
Swati Sinha
 
 
Question
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? 
Rank Answer Posted By  
 Question Submitted By :: Kunal
This Interview Question Asked @   IBM , Vertext Software Pune
I also faced this Question!!   © ALL Interview .com
Answer
let a,b,c,d,e,f,g be the 7 balls,
group them 
a and b group 1
b and c group 2 and others one group
 weigh group 1 against group 2
if they are not equal weigh the individual balls with 
respect to each other 

if they are not equal(group 1 is not equal to group 2) 
weigh e against f, if they are not equal heaviest among 
them is ur answer else g is the answer.
 
0
Srini
 
 
Answer
(Step-1)Divide the balls into 2 groups of 3 each, and weigh 
them. If they weigh same, then the 7th ball outside is the 
heaviest.
(Step-2) If not then, 
one of the 3 balls group being weighed is heavier. Take 
them down and consider the heavier group, with one ball on 
each side of the balance. 
(Step-3)if they measure unequal, then the heavier one is 
detected, and if they measure equal then the one outside is 
heavier.
 
3
Subir
 
 
Answer
Sorry guys, you failed the interview, and you got the 
question wrong. It is what is the least number of 
weighings - the answer is 2 not 3.
1) Take 2 random groups of 3 balls, compare them. If they 
are the same you got lucky - the heavier ball is the one 
you didn't weigh. If they are different you need step 2
2) Take the 3 heavier balls from weighing 1) and randomly 
compare 2 of them. If one is heavier, that is the hevier 
ball - if tehy are the same, then the one you didn't weigh 
is the heavy one.
 
0
Simon Y
 
 
Question
What is multiple inheritance ?
Rank Answer Posted By  
 Question Submitted By :: Wilbur J. Pereira
This Interview Question Asked @   Ness-Technologies , Softvision Solution, Ness
I also faced this Question!!   © ALL Interview .com
Answer
one derived class with several base class.
 
0
Aswini.s
 
 
Answer
From the existing class we can derive more class is called 
inheritance.
from the one derived class we can create several  base 
class.
 
0
Priya
 
 
Answer
derived means existing class.
base means new class from the existing class.
multiple class is defined as from one derived class we can 
create several base class
 
0
Priya
 
 
Answer
multiple inheriance is that base class can excess members 
frm derived class
 
0
Varsha Vilas Kalebag
 
 
Answer
The mechanism in which , A Call which is created my 
deriving more than one classes is called Multiple 
Inheritance.
 
0
Shivaramraje Nimbalkarjoshi
 
 
Answer
Multiple Inheritance is that one derived class having more
than one base class.

C/C++ will support multiple inheritance.
Java does not support multiple inheritance.
 
3
Sri
 
 
Answer
Multiple Inheritance is a feature of OOPS where the derived
class can extend features from more than one class.

That means if we have class A and class B then class C can
extend class A and class B.

Having said that from Java point of view this feature is not
supported as it may result in Diamond Problem.

C++ does support this features.

 
0
Funny Guy
 
 
Answer
[Base Classes]
      music      name     height
          \\      ||     //
           \\     ||    //
            \\    ||   //
             \\   ||  //
               Musician
          [Example of multiple
            inheritance]
Def.: A class derived from 2 or more superclass is called a
class inherited from by multiple inheritance.
 
0
Rohan
 
 
Question
How would you stop a class from class from being derived or 
inherited.
Rank Answer Posted By  
 Question Submitted By :: Wilbur J. Pereira
This Interview Question Asked @   Ness-Technologies
I also faced this Question!!   © ALL Interview .com
Answer
By Declaring the Class as 'Sealed' in C# or 
as "NotInheritable" in VB.NET
 
0
Satya
 
 
Answer
#define DO_NOT_DERIVE(T)		                \
	class NoDerive_##T {		                \
		friend class T;		
	                \
		NoDerive_##T() {}	        
	        \
        NoDerive_##T(const NoDerive_##T&) {}    \
	};
#define stopderiving(T) private virtual NoDerive_##T

when we derive from any class, the constructor needs to be 
called, since here constructor of NoDerive calss is 
private, it cannot be  derived. And friendship cannot be 
inherited. 
usage
class finalclass : stopderiving (finalclass)
{
....
};

the other possible solution for this is making the default 
constructor private.
 
0
Srini
 
 
Answer
make class static then it will not derive
 
0
Mohit Jethva
 
 
Answer
The class shoul be made abstract to stop it from being 
derived or inherited. To make a class abstract, it should 
have atleast one pure virtual function.
 
0
Vishaka
 
 
Answer
Make constructor of the class as private.
 
0
Ravinandan
 
 
Answer
Only fifth answer is correct (for C++)
 
0
Abhijit Pritam
 
 
Answer
class ASealedClass;

class MyFinalClass
{
friend ASealedClass;

private:
MyFinalClass(int dummy) {}
};


class ASealedClass : virtual MyFinalClass
{
public:
ASealedClass() : MyFinalClass(0) {} // this is the key .. it
is the virtual inheritance that prevents inheritance
};
 
0
Abhijit
 
 
Question
Can we have a private virtual method ?
Rank Answer Posted By  
 Question Submitted By :: Wilbur J. Pereira
This Interview Question Asked @   Ness-Technologies
I also faced this Question!!   © ALL Interview .com
Answer
No, we can't have private vitual method.

 
0
Rajendra Gandhi
 
 
Answer
no, we cann't hav private virtual method as virtual is used 
in case of inheritance but private members cannot be 
inherited..
 
0
Nidhi Singh
 
 
Answer
Yes , It we can have a private virtual method. It has 
nothing to do with inheritance. It only resolve the dynamic 
binding . Only difference is that , this method should be 
used inside the class defination of the Base .
The derived class may implements the method either 
public,private or protected.
Exa:

class A
{
	virtual void x(){cout<<"A"<<endl;};
public:
};
class B:public A
{
  //virtual void x(){cout<<"B"<<endl;}; // no prob
public:
  virtual void x(){cout<<"B"<<endl;};
};
int main()
{
 A *a;
 B *b=new B;
 a=b;
 a->fn();
}
Out put:
  B
 
3
Gopinath Das
 
 
Answer
We can have virtual functions as long as we dont call the 
function from a base pointer pointing to the base 
class/derived class.

If we call then gives error.

The same error can be tested by compiling and running above 
example.
 
0
Nk
 
 
Answer
We can have the private virtual method. But it can be 
accessed only through the derived class not through the 
base class.

class A
{
private:
	virtual void fun() { std::cout << "A::fun" << 
std::endl; }
	
};

class B : public A
{
public:
	virtual void fun() { std::cout << "B::fun" << 
std::endl; }
	
};

int main(int argc, char* argv[])
{
 A* pa = new A();
 ((B*)(pa))->fun();
}

Output : A::fun
 
0
Sriram
 
 
Question
Can we have a private constructor ?
Rank Answer Posted By  
 Question Submitted By :: Wilbur J. Pereira
This Interview Question Asked @   Ness-Technologies
I also faced this Question!!   © ALL Interview .com
Answer
yes
and if a constructor is made private/protected...then that 
class cannot be inherited
 
2
Prabha Govind
 
 
Answer
no,
we can not make a constructor private , if we make a
constructor private its method cannot access in main method .
 
0
Ravi`
 
 
Answer
We can make a constructor Private or protected.
1. Private constructor is classic example of implementing a 
singleton class( A class with a single instance)
2. Protected constructors can be used when the class cannot 
be instantiated but can only be inherited.
 
0
Srikanth
 
 
Answer
yes , we can creat private constructor trrough static 
method we can access the class (constructor), for example 
singleton, there are a lot of use in design pattern
here is example of single ton 
class Singleton {
    static Singleton s;
    int i;
Singleton(int x) : i(x) { }
void operator=(Singleton&);
Singleton(const Singleton&);
public:
static Singleton& getHandle() {
return s;
}
int getValue() { return i; }
void setValue(int x) { i = x; }
};
Singleton Singleton::s(47);
int main() {
Singleton& s = Singleton::getHandle();
cout << s.getValue() << endl;
Singleton& s2 = Singleton::getHandle();
s2.setValue(9);
cout << s.getValue() << endl;
} ///:~
 
0
Baikunta
 
 
Answer
1. Yes we can make a constructor private. By implementing 
this concept we can create a singleTon class.

2. Suppose we have a static method is a class that is used
to create the object of the class by using private
constructor then that member function is named as "Named
Constructor".

3. Using this named constructor concept we can create
SingleTon class as well as normal class.

Example:
class Singleton 
  {
  public:
      static Singleton* Instance();
  protected:
      Singleton();
      Singleton(const Singleton&);
      Singleton& operator= (const Singleton&);
  private:
      static Singleton* pinstance;
  };
 Singleton* Singleton::pinstance = 0;// initialize pointer
  Singleton* Singleton::Instance () 
  {
    if (pinstance == 0)  // is it the first call?
    {  
      pinstance = new Singleton; // create sole instance
    }
    return pinstance; // address of sole instance
  }
  Singleton::Singleton() 
  { 
    //... perform necessary instance initializations 
  }
Singleton *p1 = Singleton::Instance();
  Singleton *p2 = p1->Instance();
  Singleton & ref = * Singleton::Instance();
 
0
Arun
 
 
Answer
#include<iostream>
using namespace std;

class Singleton 
{
  public:
      static Singleton* Instance();
  private:
      static Singleton* pinstance;
	  Singleton();
};

Singleton* Singleton::pinstance = 0;// initialize pointer
Singleton* Singleton::Instance () 
{
    if (pinstance == 0)  // is it the first call?
    {  
      pinstance = new Singleton; // create sole instance
    }
    return pinstance; // address of sole instance
}
Singleton::Singleton() 
{ 
    //... perform necessary instance initializations 
}

void main()
{
		Singleton *p1 = Singleton::Instance();
		cout<<p1<<endl;
		Singleton *p2 = p1->Instance();
		cout<<p2<<endl;
		Singleton & ref = * Singleton::Instance();
}
 
0
Arun
 
 
Answer
#include<iostream>
 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<<value<<endl;
       }
     ~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...
 
0
Manjunath
 
 
Answer
Used mainly to control the object creation...
Ex: the Number of user Login's we can restrict to 15 by 
creating 15 objects...
 
0
Manjunath
 
 
Question
what is multi level inheritance give n example ?
Rank Answer Posted By  
 Question Submitted By :: Wilbur J. Pereira
This Interview Question Asked @   Ness-Technologies , Hulas Steel Company
I also faced this Question!!   © ALL Interview .com
Answer
The best example is Say we have 3 class
ClassA,ClassB and ClassC.

ClassB is derived from ClassA and ClassC is derived ClassB 
this is multi level inheritance..

        ClassA
          ^
          |
          |
        ClassB
          ^
          |
          |
        ClassC
 
0
Roshan P R
 
 
Answer
derived a new class from another derived class.It is known 
as multilevel inheritance.
example:
grandfather->father->son.
 
0
Aswini.s
 
 
Question
features of OOPS
Rank Answer Posted By  
 Question Submitted By :: Wilbur J. Pereira
This Interview Question Asked @   Ness-Technologies
I also faced this Question!!   © ALL Interview .com
Answer
1. Encapsulation: Binding of Code and data together in a 
single entity
2. Polymorphism: One name many properties (funtion 
Overloading)
3. Inheritance:Acquiring properties of one object to another
 
3
Praveen
 
 
Answer
class,objects,inheritance,encapsulation,constructor,abstrcti
on,polymorphism.
 
2
Vandana
 
 
Answer
object oriented programmimg structures
 
0
Varsha Vilas Kalebag
 
 
Answer
Abstration   : hiding essential features and showing non
essential features.
 
Encapsulation : grouping the code and data.

Inheritence   : aquiring the properties of one class into other.

polymariphism : one function many forms.
 
0
Ravi
 
 
Answer
Class: an Abstract Model of a real world entity or Concept 
or thinking. Like Car , Human being, PayRoll,etc.

Object: An instance( which is besically representing the 
class)shows class's attributes through some public or 
private method(internally)

Method: private or public functions associted with a Calss 
to access the Class (Object)

Massage Passing: Interaction(exchanging data) between two 
objects

Abstraction : This is a concept by which we only acess the 
necessary attributes of that calsss without knowing more 
about the other attrkibutes or  methods opf that cals( some 
waht like wrapping)

Encapsulation: Hiding data (attributes of a class from 
other)by eclaring private , public etc

Inheriatance: Creating new class from patrent class. As 
Mammal class is inherited from Animal Class again Human 
being is achild class of Mammal

polymorphism: method overloading, virtual functions
 
2
Pratap557
 
 
Question
What is polymorphism ? Explain with examples
Rank Answer Posted By  
 Question Submitted By :: Wilbur J. Pereira
This Interview Question Asked @   Ness-Technologies
I also faced this Question!!   © ALL Interview .com
Answer
Polymorphism means one name,many properties.Example of 
polymorphism is function overloading whare we can have many 
functions with same name but having different properties 
like the number of arguments in the function header.
 
0
Nisha
 
 
Answer
The previous example is overloading not polymorphism.

Polymorphism is multiple classes having the same method - 
for example - a DOG and CAT class that are sub classes of 
ANIMAL - ANIMAL has a virtual function - SPEAK. DOG 
implements speak via System.out.println("WOOF") and CAT 
implements it as System.out.println("MEOW") then 

ANIMAL anim = null;
anim = New DOG();
anim.speak();
anim = New CAT();
anim.speak()

will each put out the appropriate string.
 
0
Danneel
 
 
Answer
polymorphism  means many forms,greekword-poly-many fuction 
overloding,fuction overloding,operator overloding.
ex->'+'
this opertor can be overloaded to add strings 
(concatenation)or sets(union)and so on. functions also can 
be overloaded as show in the next sectin.the 
terms 'Overloading'and 'polymorphism' are used 
interchangeablely.
 
0
Ashok Kumar
 
 
Answer
Polymorphism means one in many forms.It describes a method 
in different characteristics. A method gets differentiated 
by its Function signature. Function signatures are 
datatypes, Number of parameters used in method. For 
example, a method called Calculation has different 
character such as add, sub, mul, div, etc.
 
0
Selvi
 
 
Answer
Polymorphism means "A single function which is used for 
different purposes depending upon the parameters passed"

for eg;
            Area is the function name which is used for 
calculating areas of the rectangle, triangle and even more.
from this persepective we conclude that area is the single 
function which is used for calculating different ones.
     area(a);---> Area of the square

     area(l,b);---> Area of the rectangle.
 
0
K.r.sukumar
 
 
Answer
POLYMORPHISM is derived from two latin words poly(means-
many) and morphs(means-forms).this concept of OOPS provides 
one function to be carried out in several ways or on 
several object types.
working:-The polymorphism is the ability of responding 
different object in there own way to a particular 
message.so,when message is sent requesting an object to do 
particular function,the message names the function the 
object should perform.beacause diffrent objects can have 
different functions with same name,the meaning of the 
message must be decided with respect to the particular 
object that recieved the message.so,the same message sent 
to two different objects can invoke two different functions.

example:-If a brazilian is commanded to speak(),he/she may 
speak portuguese. However, if a indian is commanded to speak
(), he/she may speak hindi. They both inherit speak() from 
human, but their Subclass methods override the methods of 
the Superclass; this is Overriding Polymorphism and 
Inheritance. Adding a walk class to human would give both 
indian and brazilian object's the same walk method.

// Assembly: Common Classes
// Namespace: CommonClasses
 
public interface Ihuman
{
    string Name
    { 
         get; 
    }
    string Talk();
}
 
// Assembly: human
// Namespace: human
 
public class humanBase
{
    private string _name;
    AnimalBase(string name)
    {
       _name = name;
    }
    public string Name
    {
       get
       {
          return _name;
       }
    }
}
 
// Assembly: human
// Namespace: human
 
public class indian : humanBase, Ihuman
{
    public indian(String name) :
        base(name)
    {
    }
 
    public string Talk() {
        return "hindi!";
    }
}
 
// Assembly: human
// Namespace: human
 
public class brazil : humanBase, Ihuman
{
    public brazil(string name) : 
        base(name)
    {
    }
 
    public string Talk() {
        return "portuguese";
    }
}
 
// Assembly: Program
// Namespace: Program
// References and Uses Assemblies: Common Classes, human
 
public class Testhuman
{
    // prints the following:
    //
    // ram: hindi!
    // Mr. harsh: hindi!
    // Lara: portuguese!
    //
    public static void Main(String[] args)
    {
        List<Ihuman> human = new List<Ihuman>();
        human.Add(new indian("ram"));
        human.Add(new indian("Mr. harsh"));
        human.Add(new brazilian("Lara"));
 
        foreach(Ihuman human in human)
        {
             Console.WriteLine(human.Name + ": " + 
human.Talk());
        }    
    }
}
 
0
Manjeet
 
 
Question
What is the difference between and interface and an 
abstract class ?
Rank Answer Posted By  
 Question Submitted By :: Wilbur J. Pereira
This Interview Question Asked @   Ness-Technologies , Ness Technologies
I also faced this Question!!   © ALL Interview .com
Answer
What is an Interface?

An interface is a contract, a specification that concrete 
classes MUST follow. It defines method signatures but 
cannot have any implementations; the latter must be 
provided by the classes that implement the interface.

C# differs from C++ in this regard because C++ lacks native 
language support for interfaces. As a C++ programmers you 
have to create an interface by defining an abstract class 
with pure virtual methods.

what is an abstract class.................

An Abstract class lets you define some behaviors and force 
your subclasses to provide others. 
For example, if you have an application framework, an 
abstract class may provide default services such as event 
and message handling. Those services allow your application 
to plug in to your application framework. However, there is 
some application-specific functionality that only your 
application can perform. So instead of trying to define 
these behaviors, the abstract class can declare abstract 
methods.

Differences between Interfaces and Abstract classes Which 
we use ?

I. multiple inheritance

A class may implement several interfaces but can only 
extend one abstract class.

II. default implementation

An interface cannot provide any code at all, much less 
default code. An abstract class can provide complete code, 
default code, and/or just stubs that have to be overridden.

III. adding functionality

If you add a new method to an interface, you must track 
down all implementations of that interface in the universe 
and provide them with a concrete implementation of that 
method. 
If you add a new method to an abstract class, you have the 
option of providing a default implementation of it. Then 
all existing code will continue to work without change.

IV. is-a vs -able or can-do

Interfaces are often used to describe the abilities of a 
class, not its central identity, e.g. an Automobile class 
might implement the Recyclable interface, which could apply 
to many otherwise totally unrelated objects.

An abstract class defines the core identity of its 
descendants.

********************************************************

There are lost of discussion on the internet about the 
Interface vs Abstract class. Also, as base class whether we 
have to use interface, abstract class or normal class.

I am trying to point out few considerations on which we can 
take decision about Interface vs Abstract class vs Class.

Abstract Class vs Interface 

I am assuming you are having all the basic knowledge of 
abstract and interface keyword. I am just briefing the 
basics.

We can not make instance of Abstract Class as well as 
Interface. 

Here are few differences in Abstract class and Interface as 
per the definition.

Abstract class can contain abstract methods, abstract 
property as well as other members (just like normal class).

Interface can only contain abstract methods, properties but 
we don?t need to put abstract and public keyword. All the 
methods and properties defined in Interface are by default 
public and abstract.

 
//Abstarct Class

public abstract class Vehicles
{
        private int noOfWheel;
        private string color;
        public abstract string Engine
        {   
          get;
             set;
        }
        public abstract void Accelerator();
}

//Interface
public interface Vehicles
{
string Engine
         {   
              get;
              set;
}
void Accelerator();
}

We can see abstract class contains private members also we 
can put some methods with implementation also. But in case 
of interface only methods and properties allowed.

We use abstract class and Interface for the base class in 
our application.

This is all about the language definition. Now million 
dollar question.

Thanks
Manoj(InfoAxon Technology Limited)


 
2
Wilbur J. Pereira
 
 
Answer
ABSTRACT CLASS                             Interface

It consist of Static       It consist of non- static member 
member variables               variables

It consist of non-abstract    It consist of only abstract  
and abstract methods          methods

it consist of private and      It consist of public classes 
protected classes

It uses the keyword Extends  uses the keyword Inplements

If subclass extends the      If the subclass implements 
abstact class, cannot extend interface, can implement any  
any other class               number of interfaces
 
0
Sathish Kumar.t
 
 
Question
write a program for function overloading?
Rank Answer Posted By  
 Question Submitted By :: Sandeep
I also faced this Question!!   © ALL Interview .com
Answer
#include<iiostream.h>
class overload
{
public:
int max(int,int);
floatmax(float,float);
};
int overload::max(int num1,int num2)
{
if(num1>nmu2)
{
return num1;
}
else
{
return num2;
}
}
float overload::max(float num1,float num2)
{
if(num1>num2)
{
return num1;
}
else
{
return num2;
}
}
int main(90
{
overload o1;
cout<<"o1.max(5.4f,8.6f)<<endl;
cout<<"o1.max(19,34)<<endl;
}
 
2
Nekkanti Rajesh
 
 
Answer
8.6 for float
34 for int
 
0
N. Sakthi Ganesh
 
 
Answer
FYI

for overloading a function differing only by return type is 
illegal (it is legal to use different a return type with a 
different argument list, though) :
 
0
Nk
 
 
Answer
Program illustrating function overloading

# include<iostream.h>
# include<conio.h>
int area(int side)
{
	return side*side;
}
int area(int l , int b)
{
	return l*b;
}

void main()
{
clrscr();
int (*p1)(int);
int (*p2)(int,int);

p1=area;
p2=area;

cout<<"Address of area(int)="<<(unsigned int)p1<<endl;
cout<<"Address of area(int,int)="<<(unsigned int)p2<<endl;

cout<<"Invoking area(int) via p1 "<<p1(20)<<endl;
cout<<"Invoking area(int,int) via p2 "<<p2(10,20);
getch();
}
 
0
Abhishek.karal
 
 
Question
what is the basic concept of inheritance?
Rank Answer Posted By  
 Question Submitted By :: Sandeep
I also faced this Question!!   © ALL Interview .com
Answer
Inheritance refers to, the object of one class acquires  
the properties of object of another class.

 Ex: 'robbin' belongs to the catagiry 'flying bird' but it 
also belongs to the catagiry of 'bird'.
  
  Thus it refers to,each derived class shares comman 
characteristics with the class from which it is derived.
 
0
Sandeep
 
 
Answer
the concept behind the inheritance is that we can create a 
object of another class and getting all the characteristics 
of the base class.the class who get characteristic is 
called derived class because it is deriving from the base 
class.the class from which class is derived is called base 
class.so, we can create another class from the existing 
one.this is the greatest advantage.
 
0
Ashwini Bhusari
 
 
Answer
Inheritance is a concept where an object of one class
acquires the properties of another class.
 
0
Prashant
 
 
Question
What is a mixin class?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
A class that provides some but not all of the 
implementation for a virtual base class is often called 
mixin. Derivation done just for the purpose of redefining 
the virtual functions in the base classes is often called 
mixin inheritance. Mixin classes typically don't share 
common bases..
 
0
Sonali
 
 
Answer
Mixin is a class that does not implement any method but are 
in fact has only pure virtual methods. The implementor 
decides the logic for these methods.

The term mixin were originally explored in the Lisp 
language In C++, the term has been used to describe classes 
in a particular (multiple) inheritance arrangement:

As superclasses of a single class that themselves have a 
common virtual base
class .

We would like to specify an extension without pre-
determining what exactly it can extend. This is equivalent 
to specifying a subclass while leaving its superclass as a 
parameter to be determined later. The benefit is that a 
single class can be used to express an incremental 
extension, valid for a variety of classes.
 
0
Reejusri
 
 
Answer
Mixin is a class that does not implement any method but are 
in fact has only pure virtual methods. The implementor 
decides the logic for these methods.

The term mixin were originally explored in the Lisp 
language In C++, the term has been used to describe classes 
in a particular (multiple) inheritance arrangement:

As superclasses of a single class that themselves have a 
common virtual base
class .

We would like to specify an extension without pre-
determining what exactly it can extend. This is equivalent 
to specifying a subclass while leaving its superclass as a 
parameter to be determined later. The benefit is that a 
single class can be used to express an incremental 
extension, valid for a variety of classes.
 
0
Reeju Srivastava
 
 
 
Back to Questions Page
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com