Exforsys
+ Reply to Thread
Results 1 to 3 of 3

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...

  1. #1
    narendra.b is offline Junior Member Array
    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


  2. #2
    sujeet.varshney is offline Junior Member Array
    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


  3. #3
    studying is offline Junior Member Array
    Join Date
    Aug 2010
    Answers
    1
    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



Latest Article

Network Security Risk Assessment and Measurement

Read More...