Geeks Talk

Prepare for your Next Interview




Dynamic Polymorphism in C

This is a discussion on Dynamic Polymorphism in C within the C and C++ forums, part of the Software Development category; How can we obtain dynamic polymorphism in C? (read my question fully) how to maintain two different types of records (say student and employee) using linked list (with the concept ...


Go Back   Geeks Talk > Software Development > C and C++

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-17-2008
Junior Member
 
Join Date: Apr 2008
Location: India
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
mkannanmca86 is on a distinguished road
Dynamic Polymorphism in C

How can we obtain dynamic polymorphism in C? (read my question fully)

how to maintain two different types of records (say student and employee) using linked list (with the concept of queue or stack)...

But the only condition is the function for add and delete (both in queue or stack) should have a same coding for both the records, and the function will act for two different records in base of the arguments... (how can we obtain dynamic polymorphism in C, with passing the structure in dynamic) if any body will to answer plz mail the programme...
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-26-2008
Junior Member
 
Join Date: Jun 2007
Location: Redmond, WA, USA
Posts: 8
Thanks: 0
Thanked 2 Times in 1 Post
SomGollakota is on a distinguished road
Re: Dynamic Polymorphism in C

I am a little out of touch with coding. So, I may not the actual code part right. However, in theory, there are a couple different ways to achieve what you are asking. You are asking to write a function that dynamically reacts to its parameter's type. The assumption here is that the records contain comparable data (empID/StudentID, EmpName/StudentName, EmpAddress/StudentAddress etc).

One way of achieving this is by writing a template function. Another way of writing this is having a C union. Create a union of two distinct structures, one for employee data and another for student data. If you can pass the union object as your function parameter, then inside the function, you can check for the type of data being passes and have the function execute accordingly.
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Polymorphism kalayama OOPS 10 10-02-2008 01:49 AM
Dynamic Link monikasangwan QTP 6 02-21-2008 01:36 AM
Dynamic Sql susarlasireesha SQL 1 10-09-2007 07:17 AM
Polymorphism......... Sampath_Java Java 4 09-12-2007 01:50 AM
Dynamic Query nancyphilips Oracle 2 10-13-2006 06:58 PM


All times are GMT -4. The time now is 02:52 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved