Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Is there Data Abstraction in C Language? (http://www.go4expert.com/forums/data-abstraction-c-language-t5927/)

aloysiustany 19Aug2007 00:10

Is there Data Abstraction in C Language?
 
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!

DaWei 19Aug2007 01:59

Re: Is there Data Abstraction in C Language?
 
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.

shabbir 19Aug2007 08:06

Re: Is there Data Abstraction in C Language?
 
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.

aloysiustany 19Aug2007 08:11

Re: Is there Data Abstraction in C Language?
 
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?

shabbir 19Aug2007 08:32

Re: Is there Data Abstraction in C Language?
 
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.

aloysiustany 19Aug2007 08:43

Re: Is there Data Abstraction in C Language?
 
oh... i get you. thank you.

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

coderzone 19Aug2007 12:48

Re: Is there Data Abstraction in C Language?
 
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

DaWei 19Aug2007 20:58

Re: Is there Data Abstraction in C Language?
 
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

shabbir 20Aug2007 21:02

Re: Is there Data Abstraction in C Language?
 
Also you can refer to Object Oriented Programming in C


All times are GMT +5.5. The time now is 22:22.