【发布时间】:2012-04-18 23:51:51
【问题描述】:
我是 C++ 的新手,当我尝试编译我的项目时,Visual Studio 2010 Express 遇到了一个致命错误,提示“无法打开包含文件:'ofstream':没有这样的文件或目录”我的实现文件(我遇到错误的地方)如下:
#include "Character.h"
#include <iostream>
#include <ofstream>
using namespace std;
ofstream characterSave;
// Sets the character's name to what the user inputted
void Character::setName(string name)
{
// Set characterName to equal what user inputted
characterName = name;
}
// Output the character's name when called
string Character::getName()
{
// Return characterName
return characterName;
}
// Save the user's data to save.dat
void Character::saveToFile()
{
// Creates new save file
characterSave.open("character.dat");
// Writes character's name to first line of save file
characterSave << characterName << endl;
// Closes save file
characterSave.close();
}
我在网上四处搜索,但找不到其他有此问题的人。会不会是我本地的 Visual Studio Express 副本?任何帮助将不胜感激。
【问题讨论】:
标签: c++ visual-studio visual-studio-2010 ofstream