为什么我从编译器中获得this error关于不带0参数的函数?是因为我在被调用之后声明函数?C++函数不接受0参数
// HelloWorld.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
cout << "Game over!\n";
swap();
system("pause");
return 0;
}
int swap()
{
int on = 1;
int off = 0;
int temp = on;
on = off;
off = temp;
return 0;
}
您需要在使用它之前声明的一切。 –
避免'使用namespace std'并定义一个具有相同名称的函数...... – Jarod42
这是因为你被代码中'using namespace std;'行烧毁了。猜猜编译器从哪里获得'swap'? – PaulMcKenzie