Hello, I was wondering if someone would be able to help me with the following compile error
In constructor Queue<T>::Queue() [with T = jobType]:
no matching function call to jobType::jobType()
candidates are jobType::jobType(const jobType&)
jobType::jobType(bool, int)
since I dont have anything that requires a deep copy or copy constructor this is confusing the heck out of me. Any sugestions would be greatly appreciated.
The code follows <I am aware that the test driver is incomplete>
<c++ code>
#include<iostream>
#include<fstream>
#include<cstdlib>
using namespace std;
int runningjobnum = 0;
const int MAXQUEUESIZE = 30;
template<class T>
class Queue {
public:
Queue ();
Queue(const T&);
bool Enqueue (T item);
bool Dequeue (T& item);
bool Next (T& item) const;
int NumberOfItems () const;
bool IsEmpty () const;
bool IsFull () const;
void PrintQueue () const;
private:
// Object instance data
T queueArray[MAXQUEUESIZE+1]; // the queue itself
int first, last, numberOfElements;
};
class TimerType
{
public:
TimerType();
void setTimer(double time);
void increment();
void decrement();
double timereturn() const;
private:
double timer;
};
class jobType
{
public:
jobType(bool, int);
~jobType();
void incrementWaiting();
void incrementCpuTime();
double GetWaiting();
double GetCpuTime();
private:
TimerType waitqueuetime;
TimerType cpuQueuetime;
int jobnumber;
bool isCpu;
double reqtime;
};
jobType::jobType(bool jobclass, int jobnum)
{
isCpu = jobclass;
jobnumber = jobnum;
if (isCpu)
{
double reqtime = 0.1;
}
else
{
double reqtime = 0.2;
}
}
void jobType::incrementWaiting()
{
waitqueuetime.increment();
}
void jobType::incrementCpuTime()
{
cpuQueuetime.increment();
}
double jobType::GetWaiting()
{
return waitqueuetime.timereturn();
}
double jobType::GetCpuTime()
{
return cpuQueuetime.timereturn();
}
////////////////////////////////////////////
////////Start Timer Class//////////////////
TimerType::TimerType()
{
timer = 0;
}
void TimerType::setTimer(double time)
{
timer = time;
}
void TimerType::increment()
{
timer++;
}
void TimerType::decrement()
{
timer--;
}
double TimerType::timereturn() const
{
return timer;
}
///////////End timer Class////////////////
/////////////////////////////////////////
template<class T>
Queue<T>::Queue () {
first = 0;
last = 0;
numberOfElements = 0;
}
template<class T>
bool Queue<T>::Enqueue (T item) {
bool retValue = false;
// Is the queue already full?
if (numberOfElements < MAXQUEUESIZE) {
retValue = true;
last = (last+1) % MAXQUEUESIZE;
queueArray[last] = item;
numberOfElements++;
// Handle the special case
if (numberOfElements == 1) {
first = last;
}
}
return (retValue);
}
template<class T>
bool Queue<T>::Dequeue (T& item) {
bool retValue = false;
// Are there elements in the queue
if (numberOfElements > 0) {
item = queueArray[first];
first = (first+1) % MAXQUEUESIZE;
numberOfElements --;
retValue = true;
}
return (retValue);
}
template<class T>
bool Queue<T>::Next (T& item) const {
bool retValue = false;
// Are there elements in the queue
if (numberOfElements > 0) {
retValue = true;
item = queueArray[first];
}
return (retValue);
}
template<class T>
int Queue<T>::NumberOfItems () const {
return (numberOfElements);
}
template<class T>
bool Queue<T>::IsEmpty () const {
return (numberOfElements == 0);
}
template<class T>
bool Queue<T>::IsFull () const {
return (numberOfElements == MAXQUEUESIZE);
}
bool jobtypechance(double iopercentage)
{
int jobtypepercentage = (rand() % 100);
bool jobtype;
if(jobtypepercentage <= iopercentage)
jobtype = false;
else
jobtype = true;
return jobtype;
}
jobType jobarrival(double iopercentage)
{
bool cpuJob = jobtypechance(iopercentage);
jobType job_one(cpuJob , runningjobnum) ;
runningjobnum++;
return job_one;
}
struct paramstype
{
int numofjobs;
double singlejobchance;
double doublejobchance;
double tensecreq;
double twentysecreq;
double thirtysecreq;
double sixtysecreq;
double ioPercentage;
};
void getparams(paramstype ¶maters)
{
double input;
cout << endl << "Please enter the total Number of jobs for the simulation" << endl;
cin >> input;
paramaters.numofjobs = input;
cout << endl << "Please enter the probibility of 1 job entering per second as a decimal" << endl;
cin >> input;
paramaters.singlejobchance = input;
cout << endl << "Please enter the probibility of 2 jobs entering per second as a decimal" << endl;
cin >> input;
paramaters.doublejobchance = input;
cout << endl << "Please enter the percentage of jobs requiring ten seconds of execution" << endl;
cin >> input;
paramaters.tensecreq = input;
cout << endl << "Please enter the percentage of jobs requiring twenty seconds of execution" << endl;
cin >> input;
paramaters.twentysecreq = input;
cout << endl << "Please enter the percentage of jobs requiring thirty seconds of execution" << endl;
cin >> input;
paramaters.thirtysecreq = input;
cout << endl << "Please enter the percentage of jobs requiring sixty seconds of execution" << endl;
cin >> input;
paramaters.sixtysecreq = input;
cout << endl << "Please enter the percentage of jobs that will be I/O bound" << endl;
cin >> input;
paramaters.ioPercentage = input;
cout << endl << endl;
}
int main()
{
Queue<jobType> waitqueue;
Queue<jobType> cpuqueue;
paramstype paramaters;
getparams(paramaters);
double jobarrivalchance = (rand() % 100);
if (jobarrivalchance < paramaters.doublejobchance)
{
jobType job_one = jobarrival(paramaters.ioPercentage);
jobType job_two = jobarrival(paramaters.ioPercentage);
waitqueue.Enqueue(job_one);
waitqueue.Enqueue(job_two);
}
else if ((!(jobarrivalchance < paramaters.doublejobchance)) && (jobarrivalchance < paramaters.singlejobchance))
{
jobType job_one = jobarrival(paramaters.ioPercentage);
waitqueue.Enqueue(job_one);
}
}
<end code>
Thank you for your time
-Ed