Thursday, July 9, 2009

What are real time examples of Inheritance, Polymorphism ,Encapsulation , Virtual functions in c++?

What is meant by "Real Time Example"? What should one say when he is asked the above c++ question in an interview?

What are real time examples of Inheritance, Polymorphism ,Encapsulation , Virtual functions in c++?
For Inheritance:





Aquiring some of the common qualities from parents (for instance eyes like mother, a mole like father etc..) is called inheritance. can also be defined as aquiring some property from others is called inheritance. based on the sources its different.





For Polymorphism:


It means multiple possible states for a single property. For example, we will act as a student as well as friend, brother to the teacher,other students and to our siblings (if any) at the same time. this is called as polymorphism(Poly-many,morphism-form).





Encapsulation: In general the definition is hiding the non-essential characteristics to others.





For Instance,If I want to show the gifts I have recieved from my girlfriend I'll show otherwise I'll hide them If I dont wish to.





And for Virtual Functions, I just know what does virtual mean:


virtual mean Non-Real. that menas the functions/methods which are defined under the virtual keyword are nonreal. That is Imaginary.


No comments:

Post a Comment