且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Visual C ++给我400多个错误?

更新时间:2023-02-12 15:28:11

  1. 如果要使用命名空间std,请执行以下操作:没有理由使用std ::开头的代码:您可以将其从代码中删除,也可以删除名称空间,否则它是多余且毫无意义的,而您只是为自己做更多的工作.

  1. If You're going to use namespace std; There is no reason to preface things with std:: you can remove that from your code or remove the namespace otherwise it's redundant and pointless and you're just making more work for yourself.

使用cin.get();由于开发人员提示不会自动关闭,并且您需要按提示中的某个键才能真正将其关闭,因此此处不需要.基本上是什么cin.get();也做得很好,所以这是多余的.

The use of cin.get(); is not required here as the developer prompt does not close automatically and requires you to press a key inside the prompt to actually close it. Which is basically what cin.get(); is doing as well so this is more redundancy.

最后要回答您的问题,您正在使用Visual Studio,这意味着您需要执行以下一项操作.

And finally to answer your question you're using visual studio which means you need to do 1 of the following.

  1. 在创建项目时,如果仅单击下一步并关闭预编译的标头,则会弹出一个带有下一步"和完成"选项的小框,您的当前代码将起作用.

  1. When you create your project a little box pops up with the Next and Finish option if you simply click next and turn off pre compiled headers your current code will work.

除非关闭预编译的标头,否则必须使用以下标头,并且必须将其放在所有其他标头文件之前

Unless you turn off pre-compiled headers you must use the following header and you must place it before all other header files

#include "stdafx.h"

当您设置基本的Visual Studio项目时,它将看起来像这样.您可以更改main,但必须包含microsoft标头,除非您关闭预编译的标头.

When you setup a basic visual studio project it will look like this, You can change main but you must include the microsoft header unless you turn off pre-compiled headers.

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
   return 0;
}

选择这些选项之一,您的代码将可用:)

Choose one of those options and your code will work :)