我正在使用 Qt Creator 版本 5.0.0 beta 来编写我的代码,使用带有 SP1 的 MSVC2010 并且所有更新都应用于编译。
我正在创建一个已定义的对象向量,用于存储有关我的测量公司工作的元信息。
我将以下信息存储在此结构中,变量类型然后是变量名;
#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。