其次是无效是非法的
Followed By Void Is Illegal?
我有以下C++(它还没有真正做任何事情......
#include "stdafx.h"
#include <iostream>
using namespace std;
class Ranker
{
int up, down;
public:
void set_ranks(int, int);
int rank(int, int, int, double);
}
void Ranker::set_ranks(int a, int b)
{
up = a;
down = b;
}
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
当我运行它时,它会在 MS V C++ 中显示以下错误消息
1>------ Build started: Project: rankclass, Configuration: Debug Win32 ------
1> rankclass.cpp
1>c:usersstudentdesktopsolomon w. c++rankclassrankclassrankclass.cpp(17): error C2628: 'Ranker' followed by 'void' is illegal (did you forget a ';'?)
1>c:usersstudentdesktopsolomon w. c++rankclassrankclassrankclass.cpp(18): error C2556: 'Ranker Ranker::set_ranks(int,int)' : overloaded function differs only by return type from 'void Ranker::set_ranks(int,int)'
1> c:usersstudentdesktopsolomon w. c++rankclassrankclassrankclass.cpp(13) : see declaration of 'Ranker::set_ranks'
1>c:usersstudentdesktopsolomon w. c++rankclassrankclassrankclass.cpp(18): error C2371: 'Ranker::set_ranks' : redefinition; different basic types
1> c:usersstudentdesktopsolomon w. c++rankclassrankclassrankclass.cpp(13) : see declaration of 'Ranker::set_ranks'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
这是为什么...排名器后面不跟着空?!?!
Ranker
声明后缺少分号。
它应该是:
class Ranker
{
int up, down;
public:
void set_ranks(int, int);
int rank(int, int, int, double);
}; // <--- Note semicolon
类定义后跟一个分号,在第 12 行添加一个。
相关文章:
- Openssl 1.1.1d无效使用不完整的类型"struct dsa_st"
- 无法访问嵌套类.类的使用无效
- 无法编译 rtmidi 测试 cmidiin.cpp 文件, 非法指令
- 如果用户输入无效,如何使用字符串变量-C++重复输入命令
- 如何解决错误:SCIP C++中的 SCIP 阶段无效 <10>
- 在没有参数列表的情况下使用模板名称"Event"无效,模板问题
- FFMPEG配置文件级别id大小无效
- 错误:从"int"到枚举c++的转换无效
- 如何修复此错误:className::className的无效使用
- 编写代码时C++出现错误:错误 1 错误 C2601:'circle':本地函数定义是非法的
- 为什么将值返回函数传递给重载=运算符对运算符函数有效,而对其他运算符无效
- C++-模板嵌套类的引用初始化无效
- 错误:无效的预处理指令 #i 的意思是 #if?
- 多维数组 C++ 中数组下标的类型"int[int]"无效
- 在 C++ 中使用正则表达式错误时出现问题 括号表达式中的范围无效
- 从 'int' 到 'int*' CPP 的转换无效
- 如何接受 [ENTER] 键作为无效输入并发送错误消息
- 由于无效的 ValidateRgn() 子窗口不会收到WM_PAINT消息
- C++ PTHREADS - 无效转换无效*(*)()到无效*(*)(无效*)
- 其次是无效是非法的