我正在使用Qt Creator版本5.0.0 beta来编写我的代码,MSVC2010带有SP1并且所有更新都应用于编译。
我正在创建一个对象向量,我已经定义它来存储我的测量公司的工作的元信息。
我将以下信息存储在此结构中,其中包含变量类型和变量名称;
#pragma once
#ifndef JOB_H
#define JOB_H
#include "surveyman.h"
#include "client.h"
#include "contact.h"
#include "job.h"
#include "legallocation.h"
#include "location.h"
#include <string>
#include <time.h>
#include <QDate>
using namespace std;
class job
{
public:
job();
job(int newUI, int newJobNumber, string newAddendum, string newJobType,
string newDevelopmentName, QDate newDateReceived, string newNotes,
legalLocation newJobLocation, client newCustomer, int newTotalMoneyPaid)
;
static int uniqueIdentifier;
int jobNumber;
private:
int UI;
string addendum;
string jobType;
string developmentName;
QDate dateReceived;
string notes;
legalLocation jobLocation;
client customer;
int totalMoneyPaid;
};
#endif // JOB_H
#pragma once
#ifndef LOCATION_H
#define LOCATION_H
#include <string>
using namespace std;
class location
{
public:
location();
location(string, string, string, string, string, int, string, string, string);
string getAddressLine1();
void setAddressLine1(string);
string getAddressLine2();
void setAddressLine2(string);
string getAddressLine3();
void setAddressLine3(string);
string getAddressLine4();
void setAddressLine4(string);
string getLocality();
void setLocality(string);
string getStreet2();
void setStreet2(string);
string getAdditionalStreets();
void setAdditionalStreets(string);
string getAdditionalLocalities();
void setAdditionalLocalities(string);
int getUI();
int getPostCode();
void setPostCode(int);
string toString();
string getProvince(int);
static int uniqueIdentifier;
private:
int UI;
string addressLine1;
string addressLine2;
string addressLine3;
string addressLine4;
string locality;
int postCode;
string street2;
string additionalStreets;
string additionalLocalities;
};
#endif // LOCATION_H
#pragma once
#ifndef LEGALLOCATION_H
#define LEGALLOCATION_H
#include "location.h"
#include <string>
#include <vector>
using namespace std;
class legalLocation : public location
{
public:
legalLocation();
legalLocation(location basicLocoation, vector<vector<int> > folios);
legalLocation(string, string, string, string, string, int, string,
string, string, vector<vector<string> >);
vector<vector<string> > getFolios();
private:
vector<vector<string> > folios;
};
#endif // LEGALLOCATION_H
#pragma once
#ifndef CLIENT_H
#define CLIENT_H
#include "location.h"
#include "legallocation.h"
#include <string>
#include "contact.h"
using namespace std;
class client
{
public:
client();
client(string, string, string, string, string, location, vector<contact>);
client(int, string, string, string, string, string, location, vector<contact>);
static int uniqueIdentifier;
private:
int UI;
string lastName;
string firstName;
string phone;
string fax;
string emailAddress;
location address;
vector<contact> contacts;
};
#endif // CLIENT_H
#pragma once
#ifndef CONTACT_H
#define CONTACT_H
#include <string>
using namespace std;
class contact
{
public:
contact();
contact(string, string, string, string);
static int uniqueIdentifier;
private:
int UI;
string firstName;
string lastName;
string phone;
string emailAddress;
};
#endif // CONTACT_H
当我导入需要大量代码以从一种非结构化格式获取信息的作业时,我注意到有关使用vector.push_back(temporaryJob)的三件事[实际代码是jobsDatabase.push_back(tempJob) );]
当它向矢量添加了5395个作业时,程序停止工作并给出标准的微软“程序已停止响应”窗口。
当我创建第二个矢量对象并在第一个矢量存储了5000个对象时添加到第二个矢量对象时,第二个矢量对象在发生相同错误之前达到711的大小。
当对两个矢量对象使用相同的代码并将限制提高到5350时,第二个文件在出现警告之前达到474。
答案 0 :(得分:1)
同时可能存在几个问题: