मैं सी ++ सदस्य समारोह संकेत बुला और structs में संकेत बुला के बारे में जानकारी मिल गया है से सदस्य समारोह सूचक है, लेकिन मैं एक सदस्य समारोह सूचक है कि एक संरचना के अंदर मौजूद कॉल करने की आवश्यकता है, और मैं करने में सक्षम नहीं किया गया है वाक्यविन्यास सही प्राप्त करें।कॉलिंग सी ++ एक struct
void MyClass::run() {
struct {
int (MyClass::*command)(int a, int b);
int id;
} functionMap[] = {
{&MyClass::commandRead, 1},
{&MyClass::commandWrite, 2},
};
(functionMap[0].MyClass::*command)(x, y);
}
int MyClass::commandRead(int a, int b) {
...
}
int MyClass::commandWrite(int a, int b) {
...
}
यह मैं देता है:: मैं एक विधि के अंदर निम्नलिखित स्निपेट वर्ग MyClass में है।
error: expected unqualified-id before '*' token
error: 'command' was not declared in this scope
(referring to the line '(functionMap[0].MyClass::*command)(x, y);')
का उपयोग कर की सिफारिश वाक्यविन्यास त्रुटियों में परिणाम आसपास के लोगों कोष्ठक बढ़ते * या -> * न जो काम का इस दशा में। क्या कोई उचित वाक्यविन्यास जानता है?
http://stackoverflow.com/questions/990625/c-function-pointer-class-member-to-non-static-member-function इस प्रश्न से संबंधित लगता है। स्पष्टीकरण के लिए – Rudi