IM刚开这实在是烦人的错误消息。 我知道我只是在新本,但它似乎我能想出的东西类型。 谁能告诉我在哪里,我去错了吗?
在运行时的信息是: 调试断言失败! 程序:...文件:C:\ Program Files文件\微软的Visual Studio 10.0 \ VC \ \包括矢量线:932表达式:矢量下标越界
而且代码
#include "VectorIntStorage.h"
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
void VectorIntStorage::Read(istream& r)
{
char c[13];
r >> c;
r >> NumberOfInts; //gets number of ints for vector
//numberVector = new std::vector<int> numberVector;
for(int i = 0; i < NumberOfInts; i++)
{
r >> numberVector[i];
cout << numberVector[i] << endl;
if(_sortRead) //true
{
for(int k = 0; k < i; k++)
{
if(numberVector[i] < numberVector[k])
{
int temp = numberVector[k];
numberVector[k] = numberVector[i];
numberVector[i] = temp;
}
}
}
}
}
void VectorIntStorage::Write(ostream& w)
{
for(int i = 0; i < NumberOfInts; i++)
{
w << numberVector[i] << endl;
cout << numberVector[i] << endl;
}
}
void VectorIntStorage::sortStd()
{
sort(numberVector.begin(), numberVector.end());
}
void VectorIntStorage::sortOwn()
{
quickSort(0, NumberOfInts - 1);
}
void VectorIntStorage::setReadSort(bool sort)
{
_sortRead = sort;
}
void VectorIntStorage::quickSort(int left, int right)
{
int i = left, j = right;
int tmp;
int pivot = numberVector[(left + right) / 2];
while (i <= j)
{
while (numberVector[i] < pivot)
i++;
while (numberVector[j] > pivot)
j--;
if (i <= j)
{
tmp = numberVector[i];
numberVector[i] = numberVector[j];
numberVector[j] = tmp;
i++;
j--;
}
}
if (left < j)
{
quickSort(left, j);
}
if (i < right)
{
quickSort(i, right);
}
}
VectorIntStorage::VectorIntStorage(const VectorIntStorage& copying)
{
//int *duplicate = new int[(copying.NumberOfInts)];
//vector<int> *duplicate = new vector<int>;
//std::copy(numberVector.begin(), numberVector.end(), duplicate);
//numberVector = duplicate;
//NumberOfInts = copying.NumberOfInts;
}
VectorIntStorage::VectorIntStorage(void)
{
}
VectorIntStorage::~VectorIntStorage(void)
{
}