what is virtual function?
Answer Posted / nk
A virtual function is basically a like normal function but
we can override the function in the derived classes.
Now when we want to access like (fn)
Base * bptr = new Derived();
bptr->fn(); then function of the derived class will be
called only if the function is marked as virtual in the
base class.
i.e the virtual keywork tells to use the function of the
class to which it is pointing to and not to the Base class.
This is called runtime polymorphism.
| Is This Answer Correct ? | 24 Yes | 7 No |
Post New Answer View All Answers
What is abstraction in oop with example?
What are constructors in oop?
Can private class be inherited?
What is abstraction in oops with example?
What is pointer in oop?
Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.
when to use 'mutable' keyword and when to use 'const cast' in c++
What is oops and why we use oops?
What are the features of oop?
What is the purpose of enum?
write a programe to calculate the simple intrest and compund intrest using by function overlading
class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash
What is a class and object?
• What are the desirable attributes for memory managment?
How do you achieve polymorphism?