dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Compiling error

  1. #1
    Jacki Guest

    Compiling error


    Following are some compiling errors I got. Please let me know what the solution
    could be, if you could detect, by looking through following codes and the
    error message.
    void SimSupport::init_sim_support(SimSupport* sim_support,HardwareSystem*
    hardware)

    {
    sim_support->add_ptr.sim_support_fun=SimSupport:: sim_support_add_ptr;
    }

    - SimSupport and HardwareSystem are classes.
    - sim_support_fun is a pointer to the function which takes pointer to the
    class SimSupport and class HardwareSystem as its parameters.
    - sim_support_add_ptr is a function which takes same parameters.

    The error message is as follows:-

    error C2440: '=' : cannot convert from 'void (__thiscall SimSupport::*)(class
    SimSupport *,class Register *)' to 'void (__cdecl *)(class SimSupport *,class
    Register* )

    YOUR HELP WILL BE APPRECIATED


  2. #2
    Danny Kalev Guest

    Re: Compiling error

    you're trying to use a pointer to a member function as if it were a
    pointer to an ordinary function. See:
    http://gethelp.devx.com/techtips/cpp...0minJuly98.asp
    The quickl an d dirty solution is to declare the member function in
    question static. Alternative solutions are available here:
    http://gethelp.devx.com/techtips/cpp.../10min0800.asp

    Danny


    Jacki wrote:
    >
    > Following are some compiling errors I got. Please let me know what the solution
    > could be, if you could detect, by looking through following codes and the
    > error message.
    > void SimSupport::init_sim_support(SimSupport* sim_support,HardwareSystem*
    > hardware)
    >
    > {
    > sim_support->add_ptr.sim_support_fun=SimSupport:: sim_support_add_ptr;
    > }
    >
    > - SimSupport and HardwareSystem are classes.
    > - sim_support_fun is a pointer to the function which takes pointer to the
    > class SimSupport and class HardwareSystem as its parameters.
    > - sim_support_add_ptr is a function which takes same parameters.
    >
    > The error message is as follows:-
    >
    > error C2440: '=' : cannot convert from 'void (__thiscall SimSupport::*)(class
    > SimSupport *,class Register *)' to 'void (__cdecl *)(class SimSupport *,class
    > Register* )
    >
    > YOUR HELP WILL BE APPRECIATED


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