Hello World - “项目已过期” [英] Hello World - "The Project is out of Date"

查看:95
本文介绍了Hello World - “项目已过期”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好, 

我一直在尝试通过一本使用2008版Visual Studio的书来学习C ++。我按照书中的指示创建了一个项目和文件,并输入以下内容: 

I've been trying to learn C++ through a book which uses the 2008 version of Visual Studio. I created a project and the file, as the book instructed me, and typed in the following: 

#include< iostream>





int main(无效)



{

使用std :: cout;

cout<< "Hello World!\ n";;
返回0;



}

#include <iostream>


int main(void)

{
using std::cout;
cout << "Hello World!\n";
return 0;

}

同样,正如书中所述。然后它指示我使用"Start without Debugging program",它说如果输入的内容正确,则会弹出另一个窗口显示"Hello World!"。相反,它说"这个项目
已经过时了,你想建立它吗?所以我说是的,它是一些东西,给了我三个错误。其中一个是我没有写'include'stdafx.h" '。我后来才知道它必须在< iostream>之前,所以我在它之前添加了
行,如下所示: 

Again, just as the book said. Then it instructed me to use "Start without Debugging program, and it said if I typed in everything correct, another window should pop up displaying "Hello World!". Instead, it's saying that "This project is out of date, would you like to build it. So I said yes, and it something, and gave me three errors. One of them was that I didn't write ' include "stdafx.h" ' . I later learned that it has to go before the <iostream>, and so I added the line before it as follows: 

现在当我做同样的事情时,它给了我另外两个错误: 

Now when I do the same thing, it's giving me the other two errors: 

LNK2005_main已在Hello World.obj中定义

LNK2005_main already defined in Hello World.obj

LNK1169找到一个或多个多重定义符号

LNK1169 one or more multiply defined symbols found

请告诉我如何解决这个问题?我是编程的新手,对于如何摆脱这个错误没有任何想法。这本书说它以后会解释一切。现在我只需要能够运行这个Hello World程序。 

Please tell me how can I fix this? I'm new to programming, and have zero idea on how to get rid of this error. The book said it's going to explain everything later. For now I just need to be able to run this Hello World program. 

谢谢!

推荐答案

现在当我做同样的事情时,它给了我另外两个错误: 

LNK2005_main已在Hello World.obj中定义

Now when I do the same thing, it's giving me the other two errors: 

LNK2005_main already defined in Hello World.obj

LNK1169找到一个或多个多重定义的符号

LNK1169 one or more multiply defined symbols found

确保你只在.cpp文件中有一次该源代码,并且那个你需要的
t在项目中有多个.cpp文件,其中包含了
代码。



然后试试这个:



打开Build菜单,然后点击Clean Solution。



完成后,打开Build菜单,然后点击Rebuild Solution。



任何错误?



- Wayne

Make sure you only have that source code in the .cpp file once, and that
you don't have more than one .cpp file in the project that has that
code in it.

Then try this:

Open the Build menu and click on Clean Solution.

When it completes, open the Build menu and click on Rebuild Solution.

Any errors?

- Wayne


这篇关于Hello World - “项目已过期”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆