错误 3 错误 C2447:'{':缺少函数标头(旧式正式列表?
Error 3 error C2447: '{' : missing function header (old-style formal list?)?
我得到的错误是来自底部的{,但我做错了什么地方导致错误吗?我该如何解决这个问题?
#include <iostream>
#include <string>
#include<stdafx.h>
using namespace std;
char Board[9];
//Declare Functions
int main()
{
char Board[9];
//Values for playing board
Board[0] = '0';
Board[1] = '1';
Board[2] = '2';
Board[3] = '3';
Board[4] = '4';
Board[5] = '5';
Board[6] = '6';
Board[7] = '7';
Board[8] = '8';
}
int showBoard();
{ //THIS IS WHERE THE ERROR IS COMING FROM
cout << endl;
cout << Board[0] << "|" << Board[1] << "|" << Board[2] << endl;
cout << "-+-+-" << endl;
cout << Board[3] << "|" << Board[4] << "|" << Board[5] << endl;
cout << "-+-+-" << endl;
cout << Board[6] << "|" << Board[7] << "|" << Board[8] << endl;
cout << endl;
}
-
函数定义不能包含分号。去掉
int showBoard()
末尾的分号 -
您需要在使用函数之前声明它们,其中定义算作声明。所以写
int showBoard();
-
showBoard
将从全局作用域中打印(未初始化)数组board
的(未定义)值。要在main
中使用数组Board
,将其作为char*
传递给showBoard
。
相关文章:
- 错误 没有与参数列表匹配的重载函数"getline"实例
- 如何防止初始值设定项列表中的错误值?
- 从类型列表中递归删除重复项会导致编译器堆空间错误 (VS2017)
- 为什么我会收到此错误?无法将 {lb, ub} 从<大括号括起来的初始值设定项列表>转换为 float(**)(float*, int)
- 错误:"模板<类_Tp,类_Dp>类 std::unique_ptr"的模板参数列表中参数 1 的类型/值不匹配
- 为什么每当我尝试运行此链接列表删除功能时都会收到分段错误错误?
- 我将 Makefile 更改为 C++11 版本,但仍然收到列表初始值设定项错误
- 使用 C++11 时列表中出现编译错误
- 使用成员初始值设定项列表时没有匹配的函数调用错误
- 结构数组的构造函数错误,错误消息:没有构造函数实例与参数列表匹配
- 处理程序的模块列表中有一个错误的模块"WebSocketModule"
- 程序接收信号SIGSEGV,分段错误.C++列表
- 格式化输出以显示在错误列表的消息部分中
- 错误 - 列表节点未命名类型
- 错误:“列表”不是“std”的成员,错误:模板参数 2 无效
- 正在创建Visual Studio错误列表消息
- 打开 cpp 文件或视觉工作室 2013 最终剂量没有调试选项也没有错误列表
- 无法从QNetworkAccessManager访问Ssl错误列表
- 在QT中链接libCurl会给出一个庞大的C++错误列表
- Visual Studio 2012 c++构建失败,但错误列表或输出中没有任何内容