我第一次为我的数据结构类使用无序集。当我尝试在我们学校的服务器上运行此代码时,它告诉我它的架构错误。这是我的主要代码(RAJ.cpp):
#include<iostream>
#include<tr1/unordered_set>
#include "nflData.h"
using namespace std;
using std::tr1::unordered_set;
struct ihash: std::unary_function<NFLData, std::size_t> {
std::size_t operator()(const NFLData& x) const
{
return x.getDown();//Currently just trying to return a value, will not be actual has function.
}
};
int main(){
string a = "20070906_NO@IND,1,46,42,IND,NO,2,6,27,(1:42) P.Manning pass deep left to M.Harrison for 27 yards TOUCHDOWN.,0,0,2007";
string b = "20070906_NO@IND,1,46,42,IND,NO,3,6,27,(1:42) P.Manning pass deep left to [88'] for 27 yards TOUCHDOWN.,0,0,2007";
string c = "20070906_NO@IND,1,46,42,IND,NO,,,27,A.Vinatieri extra point is GOOD Center-J.Snow Holder-H.Smith.,0,0,2007";
unordered_set<NFLData, ihash> myset;
cout << "\ninsert data a";
myset.insert(NFLData(a));
cout << "\ninsert data b";
myset.insert(NFLData(b));
}
这是我在使用 g++ 成功编译后尝试运行时收到的主要错误:
./test: Exec format error. Wrong Architecture.
应该注意的是,当模板化为整数类型时,相同的代码可以正常工作