Is there Data Abstraction in C Language?

aloysiustany's Avatar, Join Date: Aug 2007
Newbie Member
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!
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
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.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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.
0
aloysiustany's Avatar, Join Date: Aug 2007
Newbie Member
Quote:
Originally Posted by shabbir
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.
So, what behavior of data are you mentioning?
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by aloysiustany
So, what behavior of data are you mentioning?
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.
0
aloysiustany's Avatar, Join Date: Aug 2007
Newbie Member
oh... i get you. thank you.

But, is there in any C language can support polymorphism and inheritance?
0
coderzone's Avatar, Join Date: Jul 2004
Team Leader
Quote:
Originally Posted by aloysiustany
oh... i get you. thank you.

But, is there in any C language can support polymorphism and inheritance?
Not really
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
What one can do and how much of that one should do aren't the same thing, of course.
Polymorphism in C
Portable Inheritance and Polymorphism in C
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Also you can refer to Object Oriented Programming in C