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::jobTyp e()
candidates are jobType::jobTyp e(const jobType&)
jobType::jobTyp e(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<iostre am>
#include<fstrea m>
#include<cstdli b>
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, numberOfElement s;
};
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 incrementWaitin g();
void incrementCpuTim e();
double GetWaiting();
double GetCpuTime();
private:
TimerType waitqueuetime;
TimerType cpuQueuetime;
int jobnumber;
bool isCpu;
double reqtime;
};
jobType::jobTyp e(bool jobclass, int jobnum)
{
isCpu = jobclass;
jobnumber = jobnum;
if (isCpu)
{
double reqtime = 0.1;
}
else
{
double reqtime = 0.2;
}
}
void jobType::increm entWaiting()
{
waitqueuetime.i ncrement();
}
void jobType::increm entCpuTime()
{
cpuQueuetime.in crement();
}
double jobType::GetWai ting()
{
return waitqueuetime.t imereturn();
}
double jobType::GetCpu Time()
{
return cpuQueuetime.ti mereturn();
}
////////////////////////////////////////////
////////Start Timer Class//////////////////
TimerType::Time rType()
{
timer = 0;
}
void TimerType::setT imer(double time)
{
timer = time;
}
void TimerType::incr ement()
{
timer++;
}
void TimerType::decr ement()
{
timer--;
}
double TimerType::time return() const
{
return timer;
}
///////////End timer Class////////////////
/////////////////////////////////////////
template<class T>
Queue<T>::Queue () {
first = 0;
last = 0;
numberOfElement s = 0;
}
template<class T>
bool Queue<T>::Enque ue (T item) {
bool retValue = false;
// Is the queue already full?
if (numberOfElemen ts < MAXQUEUESIZE) {
retValue = true;
last = (last+1) % MAXQUEUESIZE;
queueArray[last] = item;
numberOfElement s++;
// Handle the special case
if (numberOfElemen ts == 1) {
first = last;
}
}
return (retValue);
}
template<class T>
bool Queue<T>::Deque ue (T& item) {
bool retValue = false;
// Are there elements in the queue
if (numberOfElemen ts > 0) {
item = queueArray[first];
first = (first+1) % MAXQUEUESIZE;
numberOfElement s --;
retValue = true;
}
return (retValue);
}
template<class T>
bool Queue<T>::Next (T& item) const {
bool retValue = false;
// Are there elements in the queue
if (numberOfElemen ts > 0) {
retValue = true;
item = queueArray[first];
}
return (retValue);
}
template<class T>
int Queue<T>::Numbe rOfItems () const {
return (numberOfElemen ts);
}
template<class T>
bool Queue<T>::IsEmp ty () const {
return (numberOfElemen ts == 0);
}
template<class T>
bool Queue<T>::IsFul l () const {
return (numberOfElemen ts == MAXQUEUESIZE);
}
bool jobtypechance(d ouble iopercentage)
{
int jobtypepercenta ge = (rand() % 100);
bool jobtype;
if(jobtypeperce ntage <= iopercentage)
jobtype = false;
else
jobtype = true;
return jobtype;
}
jobType jobarrival(doub le iopercentage)
{
bool cpuJob = jobtypechance(i opercentage);
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(param stype ¶maters)
{
double input;
cout << endl << "Please enter the total Number of jobs for the simulation" << endl;
cin >> input;
paramaters.numo fjobs = input;
cout << endl << "Please enter the probibility of 1 job entering per second as a decimal" << endl;
cin >> input;
paramaters.sing lejobchance = input;
cout << endl << "Please enter the probibility of 2 jobs entering per second as a decimal" << endl;
cin >> input;
paramaters.doub lejobchance = input;
cout << endl << "Please enter the percentage of jobs requiring ten seconds of execution" << endl;
cin >> input;
paramaters.tens ecreq = input;
cout << endl << "Please enter the percentage of jobs requiring twenty seconds of execution" << endl;
cin >> input;
paramaters.twen tysecreq = input;
cout << endl << "Please enter the percentage of jobs requiring thirty seconds of execution" << endl;
cin >> input;
paramaters.thir tysecreq = input;
cout << endl << "Please enter the percentage of jobs requiring sixty seconds of execution" << endl;
cin >> input;
paramaters.sixt ysecreq = input;
cout << endl << "Please enter the percentage of jobs that will be I/O bound" << endl;
cin >> input;
paramaters.ioPe rcentage = input;
cout << endl << endl;
}
int main()
{
Queue<jobType> waitqueue;
Queue<jobType> cpuqueue;
paramstype paramaters;
getparams(param aters);
double jobarrivalchanc e = (rand() % 100);
if (jobarrivalchan ce < paramaters.doub lejobchance)
{
jobType job_one = jobarrival(para maters.ioPercen tage);
jobType job_two = jobarrival(para maters.ioPercen tage);
waitqueue.Enque ue(job_one);
waitqueue.Enque ue(job_two);
}
else if ((!(jobarrivalc hance < paramaters.doub lejobchance)) && (jobarrivalchan ce < paramaters.sing lejobchance))
{
jobType job_one = jobarrival(para maters.ioPercen tage);
waitqueue.Enque ue(job_one);
}
}
<end code>
Thank you for your time
-Ed