Results 1 to 2 of 2

Thread: Dynamic Polymorphism in C

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Answers
    2

    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...


  2. #2
    Junior Member
    Join Date
    Jun 2007
    Answers
    17

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact