这是我使用的代码,由于某种原因,它说有未声明的标识符
#include <string>
#include <iostream>
#include "stdafx.h"
using namespace std;
int main()
{
bool Firstboot = true;
EntryPoint();
cout << "Hello World!" << endl;
return 0;
}
int MainMenu()
{
FormatedOut("MainMenu", "Menu1", "Menu1");
}
int Menu1()
{
FormatedOut("Menu1", "SubMenuOption1", "SubMenuOption1");
}
int EntryPoint() {
FormatedOut("MainMenu", "Menu1", "Menu1");
string option;
cin >> option;
if (option == "1")
{
Menu1();
}
}
int FormatedOut(string MenuName, string FirstOption, string FirstOptionTarget) {
cout << "----------------";
cout << "| " + MenuName;
cout << "|---------------";
cout << "| ";
cout << "| " + FirstOption;
EntryPoint();
}
我已经在Visual Studio 2017的C ++中对此进行了编码
我在过去半小时内遇到的错误
C3861 'EntryPoint': identifier not found 8
C2065 'cout': undeclared identifier 9
C2065 'endl': undeclared identifier 9
C3861 'FormatedOut': identifier not found 15
C3861 'FormatedOut': identifier not found 19
C3861 'FormatedOut': identifier not found 24
C2065 'string': undeclared identifier 26
C2065 'option': undeclared identifier 26
C2065 'cin': undeclared identifier 27
C2065 'option': undeclared identifier 27
C2065 'option': undeclared identifier 28
C2065 'string': undeclared identifier 34
您能给我的任何帮助将不胜感激
答案 0 :(得分:0)
您需要为在源文件中被调用后出现的功能编写功能原型。
即在valueChanges()
之前写
main
,依此类推。您还可能会发现int EntryPoint();
也需要成为源文件的第一行,具体取决于您的编译器设置(这是MSVC使用的预编译头文件的名称)。 / p>
答案 1 :(得分:0)
编译器就像您一样从上到下读取。当它到达以下行:stdafx.h
时,它从未见过称为入口点的函数,因此会抱怨。您需要了解function prototyping
。
在使用之前放置函数的原型:
EntryPoint();
答案 2 :(得分:0)
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int EntryPoint();
int FormatedOut(string MenuName, string FirstOption, string FirstOptionTarget);
add this before main() it should work