安装 Visual Studio 2013 后的第一个构建错误。致命错误 LNK1561:必须定义入口点

Very first build error after installing Visual Studio 2013. fatal error LNK1561: entry point must be defined

我想这实际上很简单,但由于我是 C++ 的新手,所以我无法理解我做错了什么。 大多数答案(例如 this question 的答案)都表明:

project name -> Properties -> Expand Linker tab -> System -> SubSystem:

并将子系统更改为不同的类型。我试过了,但它给了我另一个错误:

fatal error LNK1120: 1 unresolved externals

所以我认为这是错误的方式。 当我创建项目时,我选择了 Visual C++ -> General -> Empty Project.

我的主要方法是int main();return 0;。我之前在 Eclipse 做过,一切都很好。

拜托,我应该配置什么才能成功启动我的项目?谢谢。

这是它的样子:

#include <iostream>

using namespace std;

class Source{
    int main(){

        cout << "out" << endl;

        return 0;
    }
};

我想你可以把它改成:

#include <iostream>
using namespace std;

//class Source{
    int main()
    {
        cout << "out" << endl;
        return 0;
    }
//};

删除 class Source{ 得到:

#include <iostream>
using namespace std;

int main()
{
    cout << "out" << endl;
    return 0;
}
#include <iostream>

using namespace std;

class Source{
     int main(){
         cout << "out" << endl;
         return 0;
     }
};

你上面的代码在一个名为 Source 的 class 中有你的 main 。

#include <iostream>

using namespace std;

int main(){
    cout << "out" << endl;
    return 0;
}

是正确的开始方式,但如果你想包含来源 class 你也可以这样。

include <iostream>

using namespace std;

class Source
{

};

int main(){

     cout << "out" << endl;

     return 0;
}