Object-Oriented Programming (OOP)
From Wikibooks, the open-content textbooks collection
Contents |
[edit] Introduction
Object-Oriented Programming aims for better code reuse and problem understanding by hiding implementation. OOP allows you to break down a problem into subgroups of related parts.OOP languages have 3 things in common 1) Objects 2) Polymorphism 3) Inheritance
[edit] Programming Paradigms
[edit] Polymorphism
Allow a single name to be reused for several related but different purposes.The purpose of polymorphism is to allow one name to be used for a general class.Depending on the type of data a specific instance of the general case is executed.
[edit] Encapsulation
Encapsulation is nothing but a combining code and data as a single unit. It is achieved by using the class concept, eg:
class addition
{
int a,b;
public:
void read()
{
cout<<"\n Enter two numbers";
cin>>a>>b;
}
void print()
{
cout<<"\n first number:"<<a;
cout<<"\n Second number:"<<b;
}
int cal()
{
return a+b;
}
}
In the above example we are combining data(a and b) and the methods (read(),print(),cal())in to a single unit called by addition. now we can access those methods by using object.
[edit] Multiple Inheritance
Is the process by which one object can inherit the properties of other objects
[edit] Objects
Objects are logical entities.They contain data and code.The code manipulates the data
[edit] External Links
[edit] Mailing Lists
- Object-Oriented Numerics List is a forum for discussing scientific computing in object-oriented environments. An archive is available.