|
what is the importance of virtual and pure virtual fuctions?
|
|
|
|
|
They allow polymorphism, where derived classes can provide different behavior for the same function calls.
For example, a Shape class can have a virtual getArea () method.
Derived classes (like Circle, Square, etc...) will provide different implementations of getArea (), which use different formulas for the area calculation. Thus, you can call getArea () on a Shape object, regardless of which concrete derived class it represents, and you'll get the correct area.
|
|
|
|
|
Yes. you are right.Using these functionality in c++ we can make good code design also.
|
|
|
|
|
Try here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Jackkrishjk wrote: what is the importance of virtual and pure virtual fuctions?
VERY important.
Nihil obstat
|
|
|
|