Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8421079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:02:42+00:00 2026-06-10T03:02:42+00:00

Anyone knows how to compile this example code under msvc2010 ? (supposedly compiles under

  • 0

Anyone knows how to compile this example code under msvc2010 ? (supposedly compiles under GCC)

class cmdLine;

struct cmdList 
{
   const char *c;
   const char *s;
   const char *h;
   void (cmdLine::*cmdFuncPtr)();
};

class cmdLine
{
   public:
     cmdLine();
     static cmdList myCmdList[];
     void test();
};

cmdLine::cmdLine()
{
}

void cmdLine::test()
{
}

cmdList cmdLine::myCmdList[] =
{
   {"xxx", "yyy", "zzzzz", &cmdLine::test},
   {"aaa", "bbb", "ccc", 0}
};

int _tmain(int argc, _TCHAR* argv[])
{
   cmdLine c;
   (c.myCmdList[0].*cmdFuncPtr) (); //error (why?)
} 

I get error C2065: ‘cmdFuncPtr’ : undeclared identifier and dont know whats wrong ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:02:44+00:00Added an answer on June 10, 2026 at 3:02 am

    Use this syntax

      (c.*c.myCmdList[0].cmdFuncPtr) ();
    

    As cmdFuncPtr is a pointer to a method of cmdLine, it needs an instance of the class to be invoked on, which is c. At the same time, cmdFuncPtr is a member of cmdList, so it needs an instance of the class where it is stored, which is c.myCmdList[0]. That’s why c shall be used twice in the expression.

    The expression presented by OP parses as: “Invoke a method on an instance of a class in c.myCmdList[0] through a method pointer stored in a standalone variable cmdFuncPtr“. Such variable doesn’t exist, that’s what the compiler complains about.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know why this doesn't compile? public class ArrayCompare{ public static void main
I'm wondering if anyone knows of a PHP library that I could compile into
I'm trying to compile an object code with a reference to one lib. This
I made this code into an executable with py2exe: # File: zipfile-example-1.py from Tkinter
Anyone knows if is possible to have partial class definition on C++ ? Something
I need to compile my GWT 1.7 project from my ant build file....anyone know
Anyone knows why my sql query doesn't work after using a try catch function?
Anyone knows the equivalent of a label control in an android device? Text box
Anyone knows a good way to use http live streaming tools on non-Mac platforms?
Anyone knows how to perform such query in Postgresql? SELECT * FROM tabA WHERE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.