Visual c++ c++;编译错误/语法错误?错误原因未知

Visual c++ c++;编译错误/语法错误?错误原因未知,visual-c++,Visual C++,所以我真的不知道我的代码出了什么问题。任何建议都会有帮助。请看我注释的代码部分(中间)。计算机告诉我一个错误,应该是“;”。支架有点问题,或者我在别的地方搞砸了,就是找不到 //Experiment2 //Creating functions and recalling them. #include <iostream> using namespace std; void a() { cout<<"You try running but trip and fall an

所以我真的不知道我的代码出了什么问题。任何建议都会有帮助。请看我注释的代码部分(中间)。计算机告诉我一个错误,应该是“;”。支架有点问题,或者我在别的地方搞砸了,就是找不到

//Experiment2
//Creating functions and recalling them.
#include <iostream>
using namespace std;

void a()
{
cout<<"You try running but trip and fall and the crazy man kills you!!!!                     HAAHAHAHHAHA.";
}


void b()
{
cout<<"You stop drop and roll and the crazy man is confused by this and leaves you alone!";
}

void c()
{
cout<<"you try fighting the man but end up losing sorry!";
}




int main()
{
int a;
int b;
int c;
int d;
a=1;
b=2;
c=3;

cout<< "Once upon a time you was walking to school,\n";
cout<< " when all of the sudden some crazy guy comes running at you!!!!"<<endl;
cout<< " (This is the begining of your interactive story)"<<endl;
cout<< "Enter in the number according to what you want to do.\n";
cout<< " 1: run away, 2:stop drop and roll, or 3: fight the man."<<endl;
cin>>d;
void checkd()
//i dont know whats wrong with the bracket! the computer gives me an error saying expected a";"
{
    if(d==1)

    {
        void a();
    }

    if(d==2)

    {
        void b();
    }

    if(d==3)

    {
        void c();
    }
}
}
//实验2
//创建函数并调用它们。
#包括
使用名称空间std;
作废
{

cout您不能在另一个函数中定义函数。您在
main
函数中定义了一个函数
checkd()

将函数体移到
main
之外,只需从
main
调用函数即可:

checkd(d);
很可能,您还希望函数获取一个需要比较的参数

而且

void a();
不调用函数
a()

a();

void checkd(int d)
{
如果(d==1)
{
a();
}
如果(d==2)
{
b();
}
如果(d==3)
{
c();
}
}
int main()
{
....
....

cout@Constantinius:该函数不接受参数,但应该接受。
void checkd(int d)

{
    if(d==1)

    {
        a();
    }

    if(d==2)

    {
        b();
    }

    if(d==3)
    {
        c();
    }
}
int main()
{
    ....
    ....
    cout<< " 1: run away, 2:stop drop and roll, or 3: fight the man."<<endl;
    cin>>d;
    checkd();

    return 0;
}