Report on 8085 Microprocessor
1. Introduction
Polymorphism in C++ is one of the core concepts of Object-Oriented Programming (OOP). It allows functions
and objects to behave differently based on the context, improving code flexibility and reusability. The term
'polymorphism' means 'many forms'.
2. Types of Polymorphism
Polymorphism in C++ can be classified into two main types:
1. Compile-time Polymorphism (Static Binding)
2. Run-time Polymorphism (Dynamic Binding)
3. Compile-time Polymorphism
Compile-time polymorphism is achieved through function overloading and operator overloading.
Function Overloading:
Allows multiple functions with the same name but different parameters.
Operator Overloading:
Allows defining custom behavior for operators based on operand types.
4. Run-time Polymorphism
Run-time polymorphism is achieved using inheritance and virtual functions.
Virtual Functions:
Page 1
Report on 8085 Microprocessor
Functions that are declared in a base class and overridden in a derived class.
The function call is resolved at runtime using a virtual table (vtable).
5. Example Code
Example of run-time polymorphism in C++:
class Animal {
public:
virtual void sound() {
cout << "Animal sound" << endl;
};
class Dog : public Animal {
public:
void sound() override {
cout << "Bark" << endl;
};
int main() {
Animal* a;
Dog d;
a = &d;
Page 2
Report on 8085 Microprocessor
a->sound(); // Output: Bark
6. Conclusion
Polymorphism enhances flexibility and maintainability in object-oriented programming. It allows programmers
to design systems that are easier to extend and modify.
Page 3