473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Strane compile error

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 &paramaters)
{
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
Nov 23 '07 #1
1 1271
weaknessforcats
9,208 Expert Mod 8TB
You JobType class has no default constructor. It has other constructors so when this situation ossurs in the template:
Expand|Select|Wrap|Line Numbers
  1. temp[late <class T>
  2. void stuff()
  3. {
  4.    T data;
  5. }
  6.  
there is no default constructor to initialize data. Since you have other constructors, the compiler is withholding its own default constructor.

Just write a default constrcutor and get on with it.
Nov 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Danny Boelens | last post by:
Hi all, today I ran into a compile error after a compiler upgrade. I made a small example to demonstrate my compile error: template<typename T1, typename T2> class A {}; class B
5
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new...
5
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace )...
10
by: Chris LaJoie | last post by:
Our company has been developing a program in C# for some time now, and we haven't had any problems with it, but just last night something cropped up that has me, and everyone else, stumped. I...
2
by: Gustavo | last post by:
After updating Windows 2000 I began to get a weird compile error message: Deleting intermediate files and output files for project 'pp - Win32 Debug'. --------------------Configuration: pp -...
6
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
9
by: ThunderMusic | last post by:
Hi, I'd like to create a compile time error in my class... maybe there's a way already built in in the framework so I can achieve what I want... I have 2 constructors in my class. One of them...
4
by: tony | last post by:
Hello! My question is about calling this method CollectData below but I get a compile error that I shouldn't have because the type parameter is correct. The compile error is the following:...
5
by: wong_powah | last post by:
#include <vector> #include <iostream> using std::cout; using std::vector; enum {DATASIZE = 20}; typedef unsigned char data_t;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.