WAP to find the ambiguities in Multiple Inheritance? How
are they
resolved.(Virtual Functions)
Answer / niraj verma
Multiple Inheritance:-
A class can inherit the attributes of two or more classes.
This is know as multiple inheritance. Multiple inheritance
allows us to combine the features of several existing
classes as a starting point for designing new classes. It is
like a child inheriting the physical features of one parent
and the intelligence of onother.
In Multiple
Inheritance the derived class inherit the properly of more
than one base class.
Example:-
# include<iosteam.h>
# include<conio.h>
Class A
{
Protected:
Int x;
Public:
Void getdata ( )
{
Cout<<”\n Enter any
number”;
Cin>>x;
}
};
Class B
Protected:
Int y;
Public:
Void getadta2 ( )
{
Cout<<”\n Enter any number”;
Cin>>y;
}
};
Class c: public A, public B
{
Private:
M, z;
Public:
Void getdata3 ( )
{
Cout<<”\n Enter
any number”;
Cin>>m;
}
Void calculate ( )
{
Z = x*y+m;
}
Void display (
)
{
Cout <<
“\n Result =”<<z;
}
};
Void main ( )
{
C obj;
Obj. getdata1 ( );
Obj. getdata2 ( );
Obj. getdata3 ( );
Obj. calculate ( );
Obj. display ( );
Getch ( );
}
| Is This Answer Correct ? | 5 Yes | 2 No |
write a program to print * * * * * *
Why it is called runtime polymorphism?
can main method be overloaded...??? How..????
What is deep and shalow copy?
What is a null tree?
write a C++ program for booking using constructor and destructor.
What is difference between function overloading and overriding?
how does a main() in C++ is different from main() in C?
What is polymorphism programming?
What is a macro? And how is a macro same as a template?
What is destructor oops?
Write a program to accept a number and to print numbers in pyramid format? for eg:for a no. 5 1 212 32123 4321234 543212345