Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/149.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 我正在上一门c++;当运行我的程序时,我会得到一个错误";WinMain@16&引用;_C++_Visual Studio Code - Fatal编程技术网

C++ 我正在上一门c++;当运行我的程序时,我会得到一个错误";WinMain@16&引用;

C++ 我正在上一门c++;当运行我的程序时,我会得到一个错误";WinMain@16&引用;,c++,visual-studio-code,C++,Visual Studio Code,main.cpp: #include <iostream> #include "person.h" using namespace std; int main(){ Person human; human.setName("frank"); cout << human.toString() << endl; cout << "Name of person with get method:

main.cpp:

#include <iostream>
#include "person.h"
using namespace std;

int main(){

Person human;

human.setName("frank");

cout << human.toString() << endl;

cout << "Name of person with get method: " << human.getName() << endl;

return 0;
}
这是我所有的程序代码。当我通过visual studio代码运行该程序时,会收到一条错误消息:“c:/mingw/bin/./lib/gcc/mingw32/6.3.0/../../../../../libmingw32.a(main.o):(.text.startup+0xa0):未定义对`WinMain@16'
collect2.exe:错误:ld返回1退出状态“

由于某些原因,您的设置设置为生成GUI可执行文件而不是控制台可执行文件。检查您的tasks.json如何在Visual Studio代码中检查此问题我希望
tasks.json
设置您的建筑。尽管您应该阅读文档。当您选择使用VSCode时,了解构建过程和编译器是非常重要的。文档在这里:问题已排序谢谢您的帮助
#ifndef PERSON_H_INCLUDED
#define PERSON_H_INCLUDED

#include <iostream>
using namespace std;

class Person
{
private:
string name;

public:
Person();
string toString();
void setName(string newName);
string getName();
};

#endif
#include "person.h"

Person::Person()
{

name = "George";
}

string Person::toString()
{
return "Persons name is: " + name;
}

void Person::setName(string newName)
{

name = newName;
}

string Person::getName()
{

return name;
}