无法将'DATA_UNIT::getc1'从类型 'char (DATA_UNIT::)()' 转换为类型 'char'
cannot convert 'DATA_UNIT::getc1' from type 'char (DATA_UNIT::)()' to type 'char'
char getc1(){return this->c1;}
我得到了这种方法作为获取
DATA_UNIT::DATA_UNIT(const DATA_UNIT& Clone)
{
this->c1=Clone.getc1;
this->c2=Clone.getc2;
this->c3=Clone.getc3;
}
使用它后,我收到此错误:
cannot convert 'DATA_UNIT::getc1' from type 'char (DATA_UNIT::)()' to type 'char'
使用您的源代码,很明显 getcN 是方法,因此您必须调用它们才能获取字符,这正是错误告诉您的:"无法将接受参数的东西转换为 char"。
此外,正如评论中已经指出的那样,使用 this->c1 访问成员是没有用的。只需 c1 即可。
相关文章:
- 枚举类的 C 样式强制转换到基础类型 char 的引用
- 无法使用类型 'const char *' 的左值初始化类型 'char *' 的成员子对象
- C++:将模板类型 char 转换为 std::string
- 获取"rw_ssid"中成员"长度"的错误请求,该成员属于非类类型"char*"
- 将"std::string {aka std::basic_string}"赋值中的不兼容类型<char>
- 成员引用基类型 'char' 不是 C++ 中的结构或联合
- 错误:请求成员 .. 是非类类型"char"
- 错误:为"运算符 std::string {aka std::__cxx11::basic_string}"指定的返回类型<char>
- 为什么类型 char 返回不同的值?
- 请求成员 'begin' in 'c' 中,它是非类类型 'char [101]' sort(c.begin(), c
- C++ 类型 "char" 的参数与类型 "const char" 的参数不兼容
- 类型 "const char *" 的参数与类型 "char *" 的参数不兼容
- 类型 "const char*" 的参数与类型 "char*" 的参数不兼容。但是为什么?:(
- 创建进程使用路径时出现错误事件:类型 "char *" 的 E0167 参数与类型 "LPWSTR" 的参数不兼容
- 类型 "const char *" 的默认参数与类型 "char *" 的参数不兼容
- 返回类型 char* 的成员函数返回在 while 循环后包含不同字符串的地址
- 接受类型char的输入的问题
- 错误:无法递增类型 'char [6]' 的值
- "char *" 类型的值不能用于初始化类型 "char" 的实体
- 类型 "char *" 的参数与类型 "LPWSTR" 的参数不兼容