小弟最近在学STLPort的STL编程,昨天还好好的运行成功的程序,今天就link出这些问题了
LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall bad_cast::bad_cast(class bad_cast const &)" (??0bad_cast@@QAE@ABV0@@Z) already defined in stlport_vc71_static.lib(locale_impl.obj)
LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: virtual __thiscall bad_cast::~bad_cast(void)" (??1bad_cast@@UAE@XZ) already defined in stlport_vc71_static.lib(locale_impl.obj)
Debug/TestSTLport.exe : fatal error LNK1169: one or more multiply defined symbols found
求高手帮忙!代码如下:
//程序:测试分数统计
//目的:通过对向量中保存的分数的操作说明怎样使用算法
#include <algorithm> //如果要使用算法函数,你必须要包含这个头文件。
#include <numeric> // 包含accumulate(求和)函数的头文件
#include <vector>
#include <iostream>
using namespace std;
int testscore[] = {67, 56, 24, 78, 99, 87, 56};
//判断一个成绩是否通过了考试
bool passed_test(int n)
{
return (n >= 60);
}
// 判断一个成绩是否不及格
bool failed_test(int n)
{
return (n < 60);
}
int main(int argc, char* argv[])
{
int total;total;
// 初始化向量,使之能够装入testscore数组中的元素
vector <int> vecTestScore(testscore,
testscore + sizeof(testscore) / sizeof(int));
vector <int>::iterator vi;
// 排序并显示向量中的数据
sort(vecTestScore.begin(), vecTestScore.end());
cout << "Sorted Test Scores:" << endl;
for (vi=vecTestScore.begin(); vi != vecTestScore.end(); vi++)
{ cout << *vi << ", "; }
cout << endl;
// 显示统计信息
// min_element 返回一个 _iterator_ 类型的对象,该对象指向值最小的那个元素。
//“*”运算符提取元素中的值。
vi = min_element(vecTestScore.begin(), vecTestScore.end());
cout << "The lowest score was " << *vi << "." << endl;
//与min_element类似,max_element是选出最大值。
vi = max_element(vecTestScore.begin(), vecTestScore.end());
cout << "The highest score was " << *vi << "." << endl;
}
是不是我编译器的问题?我用的是。.net2003+stlport4.6.2