suppose A is a base class and B is the derved class. Both
have a method foo which is defined as a virtual method in
the base class. You have a pointer of classs B and you
typecast it to A. Now when you call pointer->foo, which
method gets called?
The next part of the question is, how does the compiler
know which method to call?
Answer Posted / suchi
It depends the pointer points to the object of which class.
If the pointer points to Class A, then the method defined
in class A will be called, and if the pointer points to
class B, then the method defined in class B will be called.
| Is This Answer Correct ? | 2 Yes | 6 No |
Post New Answer View All Answers
What is pointer in oop?
What are the benefits of interface?
any one please tell me the purpose of operator overloading
what's the basic's in dot net
How long to learn object oriented programming?
What is the advantage of oop over procedural language?
What is abstract class in oops?
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 does and I oop and sksksk mean?
Can destructor be overloaded?
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?
Why do we use encapsulation in oops?
What are the important components of cohesion?
What type of loop is a for loop?
explain sub-type and sub class? atleast u have differ it into 4 points?