Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Array of pointers to a functions

Array of pointers to a functions

Scheduled Pinned Locked Moved C / C++ / MFC
helpdata-structures
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    veselin_iordanov
    wrote on last edited by
    #1

    ok i have very strange problem in first case everything is ok int (*handler[15])(int parm); int user_trans_quit(int parm); int user_trans_quit(int parm){ printf("Just a test %d", parm); return 0; } int _tmain(int argc, _TCHAR* argv[]) { handler[1]=user_trans_quit; handler[1](1); } but when i try to meke OO compiler give me this error "error C2064: term does not evaluate to a function taking 1 arguments" #pragma once class PacketHandler { private : public: PacketHandler(void); ~PacketHandler(void); int LoginAck(char *parm); void Action(int i, char *data); int (PacketHandler::*handler[255])(char *parm); }; .... #include "StdAfx.h" #include ".\packethandler.h" PacketHandler::PacketHandler(void) { handler[1]=LoginAck; } PacketHandler::~PacketHandler(void) { } int PacketHandler::LoginAck(char *parm) { return 0; } void PacketHandler::Action(int i, char *data) { handler[i](data); //error C2064: term does not evaluate to a function taking 1 arguments } 10x in advance PS:sry about my bad english

    S M J V 4 Replies Last reply
    0
    • V veselin_iordanov

      ok i have very strange problem in first case everything is ok int (*handler[15])(int parm); int user_trans_quit(int parm); int user_trans_quit(int parm){ printf("Just a test %d", parm); return 0; } int _tmain(int argc, _TCHAR* argv[]) { handler[1]=user_trans_quit; handler[1](1); } but when i try to meke OO compiler give me this error "error C2064: term does not evaluate to a function taking 1 arguments" #pragma once class PacketHandler { private : public: PacketHandler(void); ~PacketHandler(void); int LoginAck(char *parm); void Action(int i, char *data); int (PacketHandler::*handler[255])(char *parm); }; .... #include "StdAfx.h" #include ".\packethandler.h" PacketHandler::PacketHandler(void) { handler[1]=LoginAck; } PacketHandler::~PacketHandler(void) { } int PacketHandler::LoginAck(char *parm) { return 0; } void PacketHandler::Action(int i, char *data) { handler[i](data); //error C2064: term does not evaluate to a function taking 1 arguments } 10x in advance PS:sry about my bad english

      S Offline
      S Offline
      Simon W 0
      wrote on last edited by
      #2

      TRY... define "LoginAck" as a static function I am seeking... For what? Why did you ask me for what? I don't know!

      1 Reply Last reply
      0
      • V veselin_iordanov

        ok i have very strange problem in first case everything is ok int (*handler[15])(int parm); int user_trans_quit(int parm); int user_trans_quit(int parm){ printf("Just a test %d", parm); return 0; } int _tmain(int argc, _TCHAR* argv[]) { handler[1]=user_trans_quit; handler[1](1); } but when i try to meke OO compiler give me this error "error C2064: term does not evaluate to a function taking 1 arguments" #pragma once class PacketHandler { private : public: PacketHandler(void); ~PacketHandler(void); int LoginAck(char *parm); void Action(int i, char *data); int (PacketHandler::*handler[255])(char *parm); }; .... #include "StdAfx.h" #include ".\packethandler.h" PacketHandler::PacketHandler(void) { handler[1]=LoginAck; } PacketHandler::~PacketHandler(void) { } int PacketHandler::LoginAck(char *parm) { return 0; } void PacketHandler::Action(int i, char *data) { handler[i](data); //error C2064: term does not evaluate to a function taking 1 arguments } 10x in advance PS:sry about my bad english

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        (this->*handler[i])(data) See the FAQ for more: 6.5 How do I declare and use a pointer to a class member function?[^] --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt "Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"   -- Rico Mariani, CLR perf guy

        1 Reply Last reply
        0
        • V veselin_iordanov

          ok i have very strange problem in first case everything is ok int (*handler[15])(int parm); int user_trans_quit(int parm); int user_trans_quit(int parm){ printf("Just a test %d", parm); return 0; } int _tmain(int argc, _TCHAR* argv[]) { handler[1]=user_trans_quit; handler[1](1); } but when i try to meke OO compiler give me this error "error C2064: term does not evaluate to a function taking 1 arguments" #pragma once class PacketHandler { private : public: PacketHandler(void); ~PacketHandler(void); int LoginAck(char *parm); void Action(int i, char *data); int (PacketHandler::*handler[255])(char *parm); }; .... #include "StdAfx.h" #include ".\packethandler.h" PacketHandler::PacketHandler(void) { handler[1]=LoginAck; } PacketHandler::~PacketHandler(void) { } int PacketHandler::LoginAck(char *parm) { return 0; } void PacketHandler::Action(int i, char *data) { handler[i](data); //error C2064: term does not evaluate to a function taking 1 arguments } 10x in advance PS:sry about my bad english

          J Offline
          J Offline
          John R Shaw
          wrote on last edited by
          #4

          I think XSimon is correct about making LoginAck() static. You also need to forward declare your class type "class PacketHandler". Of cource I understand this is only a sample, so the lack of a contructor I am ignoring. The line "handler[1]=LoginAck;" gives the impression you are thinking that the array starts at 1, it does not, the range is 0 to 254. If you want 0 - 255 use 256 instead of 255 in your declaration. Considering where the error occurs, you probably need to declare "int (PacketHandler::*handler[255])(char *parm);" as static. God luck! INTP

          1 Reply Last reply
          0
          • V veselin_iordanov

            ok i have very strange problem in first case everything is ok int (*handler[15])(int parm); int user_trans_quit(int parm); int user_trans_quit(int parm){ printf("Just a test %d", parm); return 0; } int _tmain(int argc, _TCHAR* argv[]) { handler[1]=user_trans_quit; handler[1](1); } but when i try to meke OO compiler give me this error "error C2064: term does not evaluate to a function taking 1 arguments" #pragma once class PacketHandler { private : public: PacketHandler(void); ~PacketHandler(void); int LoginAck(char *parm); void Action(int i, char *data); int (PacketHandler::*handler[255])(char *parm); }; .... #include "StdAfx.h" #include ".\packethandler.h" PacketHandler::PacketHandler(void) { handler[1]=LoginAck; } PacketHandler::~PacketHandler(void) { } int PacketHandler::LoginAck(char *parm) { return 0; } void PacketHandler::Action(int i, char *data) { handler[i](data); //error C2064: term does not evaluate to a function taking 1 arguments } 10x in advance PS:sry about my bad english

            V Offline
            V Offline
            veselin_iordanov
            wrote on last edited by
            #5

            found the problem 10x alot i must call function in this way (this->*handler[i])(data); .. dont know way its look totaly stuped for me .. but its work :D 10x for the help

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups