Answer Posted / qapoo
A function is declared virtual in base class when u are
having same functions in both base and derived classes and
you want to access both the functions with same function
call and its done using base class pointer.
e.g
class base
{
public:
void show(){cout<<"hi"};
};
class derived:pubic base
{
public:
void show(){cout<<"bye";}
};
int main()
{
base *ptr;
base b;
derived d;
ptr=&b;
ptr->show();//base class fn is called
ptr=&d;
ptr->show();//derived class fn is called
return 0;
}
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
i got a backdoor offer in process global,Bangalore..Can i work with it?
Where is pseudocode used?
Is react oop?
What is the main feature of oop?
What is variable example?
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.
What is the advantage of oop over procedural language?
Why is polymorphism important in oop?
How do you explain polymorphism?
Which method cannot be overridden?
What is multilevel inheritance?
what are the ways in which a constructors can be called?
What is polymorphism programming?
What is polymorphism give a real life example?
What is byval and byref? What are differences between them?