473,804 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strane compile error

1 New Member
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 &paramaters)
{
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
Nov 23 '07 #1
1 1287
weaknessforcats
9,208 Recognized Expert Moderator Expert
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
2234
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
3340
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 rightType;
5
3824
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 ) Person.xsd includes Common-Naming.xsd ( anonimous schemas ) Common-Naming.xsd includes common.xsd ( both are anonimous schemas ) Compilation of Resident.xsd raise the following exception: "System.Xml.Schema.XmlSchemaException: The attribute 'oid'...
10
19732
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 have a struct that contains several different types of data. This struct is used throuout the program. Now, when I compile, I get 6 errors, all of them "Use of possibly unassigned field 'awayTime'" or "Use of possibly unassigned field 'intlTime'"....
2
3320
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 - Win32 Debug-------- ------------ Compiling... pp.cpp c:\program files\microsoft visual studio\vc98
6
2863
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 fine while the file was in the project directory. When the obsolete file was removed from the project directory, my application will no longer compile. Can someone please help with this issue? Thank in advance, Tom
9
3522
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 has mandatory parameters, I mean, they should not be null nor empty (for strings). So I'd make the validation in the constructor and generate a compile-time error if the validation does not match... Is there a way to achieve this or to specify...
4
1846
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: C:\PK\Development\Products\UTCAS\4.0\SRC\MeltPracApplication\Dialog\Composit ionForm.cs(942): Argument '1': cannot convert from 'ref MeltPracData.MeltPracDataComposition' to 'ref MeltPracCommon.IDialogPostData'
5
5048
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
9714
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.