Prepare for your Next Interview
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 ...
|
|||
|
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... |
| Sponsored Links |
|
|||
|
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. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| 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 |