interview questions.

I have an interview in a few minutes. Could you give me the most cocise and impressive answers to the following questions:
1. Define polymorphism.
2. what is vitual function/ virtual mechanism.
3. what is the difference is virtual and pure virtual functions.
4. what is a template.
kavishshuklaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jkrCommented:
1.

Ploymorphism is that a pointer to a derived class is type-compatible with a pointer to its base class, so you can use features like

class Vehicle {

public:

virtual void drive() { cout << "driving vehicle" << endl;}
};

class Bike: public Vehicle {

public:

virtual void drive() { cout << "driving a bike" << endl;}
};

class Car: public Vehicle {

public:

virtual void drive() { cout << "driving a car" << endl;}
};

Vehicle* p1 = new Car();
Vehicle* p2 = new Bike();

p1->drive(); // results in "driving a car"
p2->drive(); // results in "driving a bike"

2.

A virtual function is a member function that you expect to be redefined in derived classes. When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class's version of the function.

3.
You don't have to supply a definition for a pure virtual function. They're part of abstract base classes. Specifya  virtual function as pure by placing = 0

4.

Templates are sets of parameterized classes or functions whose functionality depend on that parameterized template type. You can instantiate a class template much like you would instantiate a normal class, but include the template arguments within angle brackets.

0
AxterCommented:
>>1. Define polymorphism.

The ability to use the same signature to get different behavior, depending on the object type.
In C++ there's Static polymorphism and dynamic polymorphism.
dynamic polymorphism is a runtime polymorphism and it's achived via virtual functions.

Static polymorphism is a compile time polymorphism, and it's achived either through templates or via overloaded functions.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.