Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C++; 学习C++,我在一个类中得到了一个操作符函数,但不知道如何调用它: class Getbytes { public: Getbytes(); int operator() (unsigned char* C1, unsigned char* C2) {do something to C1 and C2 and return int; }; } main () { Getbyes myBytes; //Here, how to call the "operator() (unsigned char* C1, unsigned char*C2)"? myBytes?? }_C++_Function_Class_Operator Keyword - Fatal编程技术网

在C++; 学习C++,我在一个类中得到了一个操作符函数,但不知道如何调用它: class Getbytes { public: Getbytes(); int operator() (unsigned char* C1, unsigned char* C2) {do something to C1 and C2 and return int; }; } main () { Getbyes myBytes; //Here, how to call the "operator() (unsigned char* C1, unsigned char*C2)"? myBytes?? }

在C++; 学习C++,我在一个类中得到了一个操作符函数,但不知道如何调用它: class Getbytes { public: Getbytes(); int operator() (unsigned char* C1, unsigned char* C2) {do something to C1 and C2 and return int; }; } main () { Getbyes myBytes; //Here, how to call the "operator() (unsigned char* C1, unsigned char*C2)"? myBytes?? },c++,function,class,operator-keyword,C++,Function,Class,Operator Keyword,您将其称为myBytes()或myBytes.operator()如果你想详细说明的话 当然,您还需要传递函数所需的参数。像myBytes(“foo”,“bar”)你可以这样称呼它 Getbytes myBytes; unsigned char s1[] = "Hello"; unsigned char s2[] = "World"; myBytes( s1, s2 ); 或 如果操作符没有更改Getbytes类的对象本身,那么应该声明如下 int operator() (unsigned

您将其称为
myBytes()
myBytes.operator()如果你想详细说明的话

当然,您还需要传递函数所需的参数。像
myBytes(“foo”,“bar”)

你可以这样称呼它

Getbytes myBytes;

unsigned char s1[] = "Hello";
unsigned char s2[] = "World";

myBytes( s1, s2 );

如果操作符没有更改Getbytes类的对象本身,那么应该声明如下

int operator() (unsigned char* C1, unsigned char* C2) const;

函数调用操作符使对象可以作为函数调用,因此您只需像任何其他函数一样“调用”对象。您的
main
缺少返回类型
main
必须用返回类型声明,并且返回类型必须是
int
。在类定义的结尾
}
之后,您还缺少一个分号。另一方面,分号不属于函数定义之后。因此,
操作符()
重载的
}
后的code>不属于那里。
int operator() (unsigned char* C1, unsigned char* C2) const;