dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: compiling error again

  1. #1
    jacki Guest

    compiling error again


    class Register
    {

    void (SimSupport::*sim_support_fun)(SELF_REFERENTIAL_SIMSUPPORT sim_support,SELF_REFERENTIAL_REGISTER
    reg);
    };

    Here, I have defined a pointer to the function. The member function to be
    accessed is from Class SimSupport. The parameters are Class SimSupport and
    Class Register.

    sim_support->add_ptr.sim_support_fun=&SimSupport::sim_support_add_ptr;

    This is how I initialized the function pointer in the function
    Init( ),defined in class Simsupport.
    Here add_ptr is a member data of type Class Register.
    Sim_support_add_ptr( ) is the function defined in the SimSupport class.

    gates[curr_gate].source->sim_support_fun(sim_support, gates[curr_gate].source);

    here, I wanted to call the function through function to the pointer from
    the function inside the Class Utility. gates[curr_gate].source is of type
    Class Register.

    I am getting error message in above function call. It says term doesnot evaluate
    to the function

    I modified it as follows:


    (gates[curr_gate].source->*sim_support_fun)(sim_support, gates[curr_gate].source);

    The error message I get now is:
    sim_support_fun is not defined. Could you plz tell me how to call the function
    through function pointer correctly.

    I shall be very grateful for your kind help.



  2. #2
    Danny Kalev Guest

    Re: compiling error again



    jacki wrote:
    >
    > class Register
    > {
    >
    > void (SimSupport::*sim_support_fun)(SELF_REFERENTIAL_SIMSUPPORT sim_support,SELF_REFERENTIAL_REGISTER
    > reg);


    Note that you didn't really define a pointer to a member function here.

    > };
    >
    > Here, I have defined a pointer to the function. The member function to be
    > accessed is from Class SimSupport. The parameters are Class SimSupport and
    > Class Register.
    >
    > sim_support->add_ptr.sim_support_fun=&SimSupport::sim_support_add_ptr;
    >
    > This is how I initialized the function pointer in the function
    > Init( ),defined in class Simsupport.
    > Here add_ptr is a member data of type Class Register.
    > Sim_support_add_ptr( ) is the function defined in the SimSupport class.
    >
    > gates[curr_gate].source->sim_support_fun(sim_support, gates[curr_gate].source);
    >
    > here, I wanted to call the function through function to the pointer from
    > the function inside the Class Utility. gates[curr_gate].source is of type
    > Class Register.
    >
    > I am getting error message in above function call. It says term doesnot evaluate
    > to the function
    >
    > I modified it as follows:
    >
    > (gates[curr_gate].source->*sim_support_fun)(sim_support, gates[curr_gate].source);
    >


    You lost me somewhere on the road but I think you should change the ->
    in the expression
    (gates[curr_gate].source->*sim_support_fun) to . In other words, try

    (gates[curr_gate].source.*sim_support_fun)(sim_support,
    gates[curr_gate].source);

    Danny

  3. #3
    Danny Kalev Guest

    Re: compiling error again



    jacki wrote:
    >
    > Hi Danny,
    >
    > gate[curr_gate].source is a pointer.


    try to parenthesize it:

    ((gate[curr_gate].source)->*sim_func)(...)

    Danny
    >
    > jacki


  4. #4
    jacki Guest

    Re: compiling error again


    Hi Danny,

    gate[curr_gate].source is a pointer.

    jacki


  5. #5
    jacki Guest

    Re: compiling error again


    Danny Kalev <dannykk@inter.net.il> wrote:
    >
    >
    >jacki wrote:
    >>
    >> Hi Danny,
    >>
    >> gate[curr_gate].source is a pointer.

    >
    >try to parenthesize it:
    >
    >((gate[curr_gate].source)->*sim_func)(...)
    >
    >Danny
    >>
    >> jacki


    it still gives the same problem.



  6. #6
    Danny Kalev Guest

    Re: compiling error again

    Jacki,
    since we don't have the complete declarations of your classes and can't
    check where the problem lies, I suggest that you create a simple demo
    project with three classes, simple define member functions in each
    class, create pointers to these members and try to call them. You're
    probably missing a syntactic quirk.

    Danny

    jacki wrote:
    >
    > Danny Kalev <dannykk@inter.net.il> wrote:
    > >
    > >
    > >jacki wrote:
    > >>
    > >> Hi Danny,
    > >>
    > >> gate[curr_gate].source is a pointer.

    > >
    > >try to parenthesize it:
    > >
    > >((gate[curr_gate].source)->*sim_func)(...)
    > >
    > >Danny
    > >>
    > >> jacki

    >
    > it still gives the same problem.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center