
- Forum
- Programming Talk
- C and C++
- example abstraction
example abstraction
This is a discussion on example abstraction within the C and C++ forums, part of the Programming Talk category; Can anybody tell me what abstraction and encapsulation is through example ? Please donot give text book answers. Thanks...
-
03-01-2010, 05:30 AM #1
- Join Date
- Mar 2010
- Answers
- 4
example abstraction
Can anybody tell me what abstraction and encapsulation is through example? Please donot give text book answers.
Thanks
-
07-12-2010, 12:42 PM #2
- Join Date
- Jul 2010
- Answers
- 7
by sujeet varshney c,c++ expert since 1996
class eg
{
int rn;
char n[20];
//by default memebers of the class are private
public:
void getd()
{
}
void dispd()
{
}
};
//encapsulation wrapping or binding up of data and functions into a single unit called class so classes are used to encapsulate data and functions
-
Data hiding
hide the information to outside world from direct use..
Abstraction is hiding internal implementation details ,just hilights the set of services to the outside world.for example..
University hides student information(like name,sex) to the examiner.but hiligthing the service as putMarks()..
class HallTicket
{
private:
char *name;
char *sex;
public:
void putMarks(){}
};
so examiner don't have any knowledge about name and sex etc..but he can put the marks by putMarks() service through the HallTicket object.
Encapsulation
holding the data behind the methods is called encapsulation..
-
Sponsored Ads

Reply With Quote





