1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Is there Data Abstraction in C Language?

Discussion in 'C' started by aloysiustany, Aug 18, 2007.

  1. aloysiustany

    aloysiustany New Member

    Joined:
    Aug 18, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    This was the question I was asked during my project review but still I am clueless about the answer.

    The question was, Is there Data Abstraction in C Language? I answered them No. Then, they asked me What is Structure and Union?. I told them, A structure is a collection of variables under a single name. These variables can be of different types, and each has a name which is used to select it from the structure. A structure is a convenient way of grouping several pieces of related information together. Now they asked me, If that is the case then how can we say that there is no Data abstraction in C? I was totally speechless at this. Still now, I don't have the answer for it.

    If you guys can help me explain me this, it would be of great help to me. Thank you very much!
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    In essence, abstraction means that one can treat problems in a way that are more convenient for the human brain to process, rather than in a ways that are more convenient for a processor of the Von Neumann type to process.

    Two different structures might have members that are named, for example, "airflow". The variable, "airflow", will have different overall effects for a construct dealing with "carburetors"" than it will for a construct dealing with "simple fan".

    C obviously presents the occasion for dealing with abstractions.
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    As per the definition of of Data Abstraction it has 2 parts and one part is possible in C but not the other one.

    Its a way to define abstract data type objects which are different from all other types of objects and so structures is way to be doing that where you can define the objects which are different from the rest but the abstraction in the real sense does not come from just grouping the data but also it should define the behavior of the data as well and that is not directly possible in C and so data abstraction is not there in C language.
     
  4. aloysiustany

    aloysiustany New Member

    Joined:
    Aug 18, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    So, what behavior of data are you mentioning?
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    In C++ I can restrict the variable data to the external world.

    I just have the Set function but not the Get function which is not possible in C and that is defining the behavior of the object. It should not behave in certain manner.
     
  6. aloysiustany

    aloysiustany New Member

    Joined:
    Aug 18, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    oh... i get you. thank you.

    But, is there in any C language can support polymorphism and inheritance?
     
  7. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    Not really
     
  8. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
  9. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83

Share This Page