Vectors, structs and casting

Hi everyone

I'm having real difficulties with a vector of structs I've created. Ideally, within a loop I'd like to create a new struct to add to the vector. However, I want each struct to be named different, So I've made an int, and named my first struct the variable, and then tried to itterate. But I get a type-cast error. This is part of a Uni assignment and I *think* I've narrowed it down to polymorphism and pointers, but it's all a bit over my head :( Can someone please help?

int JobID = 1;

//declare struct for the jobs
struct Jobs
{
int jobNumber; //unique job number
time_t timeSubmitted; //time submitted to the buffer
time_t timePrinting; //time submitted to printer
time_t printed; //time printing finished
time_t Successful; //the total time it took to print the job
};


//a vector of structs. This is my buffer.
vector <Jobs> buffer;
===============================================================================

while (currentTime <tenHourSim)
{
time (&currentTime);
//get the first time - run every 25 seconds
if (currentTime == consq){
time (&currentTime);
time_t consq = time_t (currentTime + iConsq);
cout<<"yay"<<endl;

//***send a job to a buffer***
Jobs (JobID);
JobID.jobNumber = jobCount;
JobID.timeSubmitted = currentTime;
JobID.timePrinting = currentTime;
JobID.printed = currentTime;
JobID.Successful = JobID.printed - JobID.timeSubmitted;

JobID = (int) JobID+1;



The last line is where the issue is. My compiler says 'Type-Cast': cannot cast fro 'Jobs' to 'int'
What are you trying to do with the last line?
You probably need to replace
JobID = (int) JobID+1;
with
++JobID.jobNumber;
Topic archived. No new replies allowed.