我从书中获得了C ++代码,想在Visual C ++ Express 2010中运行它,但出现类似以下的错误。您能告诉我如何运行此代码吗?
非常感谢 !

#include <iostream>

class Cat
{
public:
int itsAge;
int itsWeight;
};

int main()
{
Cat Frisky;
Frisky.itsAge = 5;
std::count << "Frisky is a cat who is ";
std::count << Frisky.itsAge << " years old.\n";

reutrn 0;
}


 ------ Build started: Project: chp6, Configuration: Debug Win32 ------
  list6_1.cpp
  list6_1.cpp(2): warning C4627: '#include <iostream>': skipped when looking for          precompiled header use
            Add directive to 'StdAfx.h' or rebuild precompiled header
  list6_1.cpp(20): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
   ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

最佳答案

在您的项目设置中,关闭预编译头。当您创建项目时(可能是默认情况下),此功能已打开,并且期望#include "StdAfx.h"是文件的第一行。

关于c++ - 如何在Visual C++ Express 2010中编译此逻辑,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10001656/

10-11 16:16