ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
How can I implement opaque (abstract) data types in C?
What's the difference between these two declarations?

	struct x1 { ... };
	typedef struct { ... } x2;
 Question Submitted By :: Roja
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How can I implement opaque (abstract) data types in C? What's the difference between these two declarations? struct x1 { ... }; typedef struct { ... } x2;
Answer
# 1
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 ?    0 Yes 0 No
Phani Kumar S
 
  Re: How can I implement opaque (abstract) data types in C? What's the difference between these two declarations? struct x1 { ... }; typedef struct { ... } x2;
Answer
# 2
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 0 No
Pankaj
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What are the preprocessors? HP6
write the function int countchtr(char string[],int ch);which returns the number of timesthe character ch appears in the string. for example the call countchtr("she lives in Newyork",'e') would return 3.  4
What is encapsulation?  1
Tell us the difference between these two : #include"stdio.h" #include<stdio.h> define in detial.  4
what is the difference between NULL & NUL keywords in C?  3
WRITE A C PROGRAM TO FIND SECOND BIGGEST VALUE FROM THE GIVEN VALUES  1
main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? } NDS15
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); } ME3
Which of the following are valid "include" formats? A)#include and #include[file.h] B)#include (file.h) and #include C)#include [file.h] and #include "file.h" D)#include <file.h> and #include "file.h" Accenture14
how to find the size of the data type like int,float without using the sizeof operator?  7
int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation. Global-Edge11
what will happen if you free a pointer twice after allocating memory dynamically ? Novell2
what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){ case 4:a+=a*r; case 3:a+=a*r; case 2:a+=a*r; case 1:a+=a*r; } } a.computes simple interest for one year b.computes amount on compound interest for 1 to 4 years c.computes simple interest for four year d.computes compound interst for 1 year TCS4
what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }  4
write a program to find out number of on bits in a number? Huawei12
How can I invoke another program from within a C program?  6
what are the static variables HCL7
what is the difference between #include<> and #include”…”?  1
How can I implement opaque (abstract) data types in C? What's the difference between these two declarations? struct x1 { ... }; typedef struct { ... } x2;  2
why division operator not work in case of float constant?  1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com