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

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,


find largest element in array w/o using sorting techniques.

3 Answers   Zycus Infotech,


what is difference between overriding and overloading?

1 Answers  


what is the output of the program and explain why?? #include<stdio.h> void main ( ) { int k=4,j=0: switch (k) { case 3; j=300; case 4: j=400: case 5: j=500; } printf (ā€œ%d\nā€,j); }

14 Answers   Oracle,


How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?

2 Answers   Aricent, Manipal University,






struct node {struct node*temp,*new} prinf("%d",sizeof(struct node));

2 Answers  


main() { float f1=10.5; double db1=10.5 if(f1==db1) printf("a"); else printf("b") }

2 Answers   CSC,


how does the C compiler interpret the following two statements p=p+x; q=q+y; a. p=p+x; q=q+y b. p=p+xq=q+y c. p=p+xq; q=q+y d. p=p+x/q=q+y

2 Answers   TCS, Tech Synergy,


Is boolean a datatype in c?

0 Answers  


what is the use of c program?

4 Answers   Synergy, Web Synergies,


What are directives in c?

0 Answers  


we compile c program in 32 processor and 64 bit processor .exe file is created in both the processors. if we want to run .exe file in 64 bit processor which is created in 32 bit processor. is that .exe file is run or not if it is not run why?

4 Answers   HP, Wipro,


Categories