नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'operation' : illegal operation on pointer to member function expression
Remarks
A pointer to member-function expression must call the member function.
Examples
The following example generates C2298.
// C2298.cpp
#include <stdio.h>
struct X {
void mf() {
puts("in X::mf");
}
void mf2() {
puts("in X::mf2");
}
};
X x;
// pointer to member functions with no params and void return in X
typedef void (X::*pmf_t)();
// a pointer to member function X::mf
void (X::*pmf)() = &X::mf;
int main() {
int (*pf)();
pf = x.*pmf; // C2298
+(x.*pmf); // C2298
pmf_t pf2 = &X::mf2;
(x.*pf2)(); // uses X::mf2
(x.*pmf)(); // uses X::mf
}
The following example generates C2298.
// C2298_b.cpp
// compile with: /c
void F() {}
class Measure {
public:
void SetTrackingFunction(void (Measure::*fnc)()) {
TrackingFunction = this->*fnc; // C2298
TrackingFunction = fnc; // OK
GlobalTracker = F; // OK
}
private:
void (Measure::*TrackingFunction)(void);
void (*GlobalTracker)(void);
};