Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How is it possible to insert different type of elements in
stack?

Answer Posted / krishan

We can use a struct containing "void * " in it and an
unsigned int to store the datatype which "void *" will store
(can be set at time of storing the value). To store a value
of any type we can dynamically allocate the space and set
the unsigned int to some pre-determined constants. Like
1 for int type.
2 for char.
3 for char string.
4 for any other type. say some user datatype.

Is This Answer Correct ?    21 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which searching algorithm is best?

941


How does insertion sort works?

926


What is breadth first tree?

1041


Evaluate the following prefix expression " ++ 26 + - 1324" (Similar types can be asked)

1026


How do you define a set?

966


What are the advantage of collection classes over arrays?

942


What is binary tree in computer science?

976


Which is the parent class of abstractqueue class?

978


Write a Program for Delete an element from a doubly linked list.

965


What is the procedure to insert into a sorted array?

1043


Explain the uses of binary tree.

972


What are the types of queues?

1151


How do you sort an arraylist?

928


How is heap sort implemented?

892


Which is better hashmap or arraylist?

1047