WAP to find the ambiguities in Multiple Inheritance? How
are they
resolved.(Virtual Functions)
Answer Posted / 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 |
Post New Answer View All Answers
write a program that takes input in digits and display the result in words from 1 to 1000
Why do we use oops?
What is encapsulation in simple terms?
Can bst contain duplicates?
Is this job good for future? can do this job post grduate student?
write a program to find 2^n+1 ?
What are different oops concepts?
What is pure oop?
How is class defined?
when to use 'mutable' keyword and when to use 'const cast' in c++
Where is pseudocode used?
Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)
#include
String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?
This program numbers the lines found in a text file. Write a program that reads text from a file and outputs each line preceded by a line number. Print the line number right-adjusted in a field of 3 spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a time and write code to ignore leading blanks on each line. You may assume that the lines are short enough to fit within a line on the screen. Otherwise, allow default printer or screen output behavior if the line is too long (i.e., wrap or truncate). A somewhat harder version determines the number of spaces needed in the field for the line numbers by counting lines before processing the lines of the file. This version of the program should insert a new line after the last complete word that will fit within a 72-character line.