【发布时间】:2014-03-24 14:01:44
【问题描述】:
我正在为我的体系结构类编写一个分支预测器模拟器,但在使输出在多个类之间工作时遇到了一些麻烦。我试图在我的 main.cpp 中打开一个 main ofstream 并将其传递给每个类的构造函数以供对象使用。我的头文件中有一大堆错误,例如:
In file included from main.cpp:4:0:
predictors.h: In constructor â?~ATPred::ATPred(std::ofstream&)â?T:
predictors.h:14:18: error: use of deleted function â?~std::basic_ofstream<char>& std::basic_ofstream<char>::operator=(
const std::basic_ofstream<char>&)â?T
所以错误似乎在我的头文件中:
#ifndef PREDICTORS_H
#define PREDICTORS_H
#include <string>
// Always Taken
class ATPred{
private:
std::ofstream outputFile;
public:
// Constructor
ATPred(std::ofstream& file)
{ outputFile = file; }
// Deconstructor
~ATPred()
{}
// Member Functions
void parseResults(std::string filename);
};
// Always Non-Taken
class ANTPred{
private:
std::ofstream outputFile;
public:
// Constructor
ANTPred(std::ofstream& file)
{ outputFile = file; }
// Deconstructor
~ANTPred()
{}
// Member Functions
void parseResults(std::string filename);
};
#endif
我不确定我在哪里出错了,所以任何帮助将不胜感激。
【问题讨论】: