How can I implement opaque (abstract) data types in C?
What's the difference between these two declarations?

struct x1 { ... };
typedef struct { ... } x2;

Answers were Sorted based on User's Feedback



How can I implement opaque (abstract) data types in C? What's the difference between these two..

Answer / phani kumar s

using the structures and the pointers
n structures the memory will be allocated for each object at
different locations struct x1 { ... };

Is This Answer Correct ?    4 Yes 0 No

How can I implement opaque (abstract) data types in C? What's the difference between these two..

Answer / pankaj

Abstract data type in C can be implemented using structures :
struct abstract;
typedef struct abstract abstract_type;

Note that this didn't define the struct abstract fully, only an opaque struct. sizeof() can be used on it. Memory can be allocated by using some macros and typecasted into this type.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

What is the sizeof () a pointer?

0 Answers  


what type of language is C?

13 Answers   Microsoft,


How to write c functions that modify head pointer of a linked list?

0 Answers  


how to find out the biggest element (or any other operation) in an array which is dynamic. User need not to mention the array size while executing.

3 Answers  


write a program which will count occurance of a day between two dates.

1 Answers   IonIdea,






What is define directive?

0 Answers  


what is default constructor?

2 Answers   HCL,


HOW DO YOU HANDLE EXCEPTIONS IN C?

2 Answers   AppLabs,


how can i make a program with this kind of output.. Enter a number: 5 0 01 012 0123 01234 012345 01234 0123 012 01 0

4 Answers   Wipro,


enum { SUNDAY, MONDAY, TUESDAY, }day; main() { day =20; printf("%d",); getch(); } what will be the output of the above program

1 Answers  


Define recursion in c.

0 Answers  


What will be printed as the result of the operation below: #include<..> int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); }

2 Answers  


Categories