Plz give an example with c++ language
What is the difference between abstraction,encapsulation,data hiding?Where they implemented in c++ ?
Abstraction means hiding complex details of creation(logic and functions) and just implenment/call them without bothering about how they work?.
Encapsulation means combining both data and function that operates on that data into a single unit(eg classes and objects in C++(or in any othe OPP).
Data Hiding means to make data invisible to external functions to minimize accidental modification/chage of important data. Following is the beast example of all the three
class employee /* Encapsultaion*/
{
private:
char name[20];
int age;
float salary;
public: /*Data Hiding, Following functions access data */
void getemployee
{
cout%26lt;%26lt; "Enter name";
cin%26gt;%26gt;name;
cout%26lt;%26lt;"Enter Age";
cin%26gt;%26gt;age;
cout%26lt;%26lt; "Enter Salary";
cin%26gt;%26gt;salary;
}
void showemployee
{
cout%26lt;%26lt;"\n Name"%26lt;%26lt;name;
cout%26lt;%26lt;"\n Age"%26lt;%26lt;age;
cout%26lt;%26lt;"\n Salary"%26lt;%26lt;salary;
}
};
void main()
{
/*Abstraction:- working defined in employee class*/
employee e1;
e1.getemployee();
e1.showemployee();
}
for more examples visit http://codesbyshariq.blogspot.com
Reply:Above features r called as OOP (Object Oriented Programming) concept.
Tutorial %26amp; Egs:
http://www.kbcafe.com/articles/OOP.Conce...
Try this site too....
http://www.exforsys.com/tutorials/c-plus...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment