在尝试调用函数时,我在下面遇到 C2064 错误。我究竟做错了什么?
//error C2064: term does not evaluate to a function taking 1 arguments
#include <iostream>
#include <string>
using namespace std;
class DXStartupEncoder {
public:
void EncodeA(string& message) const { message = "A"; }
void EncodeB(string& message) const { message = "B"; }
void EncodeC(string& message) const { message = "C"; }
void EncodeD(string& message) const { message = "D"; }
void EncodeE(string& message) const { message = "E"; }
void EncodeF(string& message) const { message = "F"; }
};
typedef void (DXStartupEncoder::*Encoder)(string&) const;
Encoder dn_sequence[] = {&DXStartupEncoder::EncodeA, &DXStartupEncoder::EncodeB, &DXStartupEncoder::EncodeC, &DXStartupEncoder::EncodeD };
Encoder queue_sequence[] = { &DXStartupEncoder::EncodeE, &DXStartupEncoder::EncodeF };
int main(int argc, char* argv[])
{
for(int i = 0; i < sizeof(queue_sequence) / sizeof(queue_sequence[0]); ++i) {
string param;
queue_sequence[i](param); //How to call function here???
cout << param << endl;
}
return 0;
}