473,796 Members | 2,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help needed on "no match function error"

I am learning template programming now, and I wrote the following code

#include <iostream>
#include "Queue.h"
using namespace std;

template <typename Tclass QueueItem
{
public:
QueueItem(T item):value(ite m),next(0){}
T value;
QueueItem *next;
};

template <typename Tclass Queue
{
private:
QueueItem<T*hea d;
QueueItem<T*tai l;
public:
Queue():head(0) ,tail(0){}
Queue(const Queue &orig):head(0), tail(0)
{
for(QueueItem<T *temp=orig.head ;temp;temp=temp->next)
{
push(temp->value);
}

}
Queue& operator=(Queue & orig)
{
head =0;
tail =0;
for(QueueItem<T *temp=orig.head ;temp;temp=temp->next)
{
push(temp->value);
}
return *this;
}
~Queue()
{
while (head)
{
cout<<"In~Queue ";
pop();
}
}
void pop();
void push(T item);
bool empty(){
if (head==0)
return 1;
return 0;
}

};

template <typename Tvoid Queue<T>::push( T item)
{
if(empty())
{
head = new QueueItem<T>(it em);
tail=head;
}
else
{
QueueItem<T*tem p;
temp = new QueueItem<T>(it em);
tail->next=temp;
tail=temp;
}
}

template <typename Tvoid Queue<T>::pop()
{
if(!empty())
{
QueueItem<T*tem p;
temp=head;
head = head->next;
cout<< "pop a value of "<<temp->value<<endl;
delete temp;
}
else
{
cerr<<"the Queue is empty, so cannot call pop function"<<endl ;
}
}

int main()
{
Queue<intorig_q ueue;
for(int i=0; i<8; i++)
orig_queue.push (i);

Queue<intcopy_q ueue;
copy_queue(orig _queue);//this line has compile error
return 0;
}

and get the compiling error :
no match for call to ‘(Queue<int>) (Queue<int>&)’ Queue Queue.cc line
103 1214317008414 99

for the line copy_queue(orig _queue): line

Could you please help me out for this problem? Thanks
Jun 27 '08 #1
2 1989
Jolie Chen wrote:
I am learning template programming now, and I wrote the following code

#include <iostream>
#include "Queue.h"
using namespace std;

template <typename Tclass QueueItem
{
public:
QueueItem(T item):value(ite m),next(0){}
T value;
QueueItem *next;
};

template <typename Tclass Queue
{
private:
QueueItem<T*hea d;
QueueItem<T*tai l;
public:
Queue():head(0) ,tail(0){}
Queue(const Queue &orig):head(0), tail(0)
{
for(QueueItem<T *temp=orig.head ;temp;temp=temp->next)
{
push(temp->value);
}

}
Queue& operator=(Queue & orig)
{
head =0;
tail =0;
for(QueueItem<T *temp=orig.head ;temp;temp=temp->next)
{
push(temp->value);
}
return *this;
}
~Queue()
{
while (head)
{
cout<<"In~Queue ";
pop();
}
}
void pop();
void push(T item);
bool empty(){
if (head==0)
return 1;
return 0;
}

};

template <typename Tvoid Queue<T>::push( T item)
{
if(empty())
{
head = new QueueItem<T>(it em);
tail=head;
}
else
{
QueueItem<T*tem p;
temp = new QueueItem<T>(it em);
tail->next=temp;
tail=temp;
}
}

template <typename Tvoid Queue<T>::pop()
{
if(!empty())
{
QueueItem<T*tem p;
temp=head;
head = head->next;
cout<< "pop a value of "<<temp->value<<endl;
delete temp;
}
else
{
cerr<<"the Queue is empty, so cannot call pop function"<<endl ;
}
}

int main()
{
Queue<intorig_q ueue;
for(int i=0; i<8; i++)
orig_queue.push (i);

Queue<intcopy_q ueue;
copy_queue(orig _queue);//this line has compile error
This syntax actually means to invoke the [non-existent] operator() for
the object called 'copy_queue' with 'orig_queue' as argument. Did you
actually mean to do

Queue<intcopy_q ueue(orig_queue );

?
return 0;
}

and get the compiling error :
no match for call to ‘(Queue<int>) (Queue<int>&)’ Queue Queue.cc line
103 1214317008414 99

for the line copy_queue(orig _queue): line

Could you please help me out for this problem? Thanks
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2
Victor,

You are right. Thank you so much.

Jolie

On Jun 24, 9:48*am, Victor Bazarov <v.Abaza...@com Acast.netwrote:
Jolie Chen wrote:
I am learning template programming now, and I wrote the following code
#include <iostream>
#include "Queue.h"
using namespace std;
template <typename Tclass QueueItem
{
public:
* *QueueItem(T item):value(ite m),next(0){}
* *T value;
* *QueueItem *next;
};
template <typename Tclass Queue
{
private:
* *QueueItem<T*he ad;
* *QueueItem<T*ta il;
public:
* *Queue():head(0 ),tail(0){}
* *Queue(const Queue &orig):head(0), tail(0)
* *{
* * * * * *for(QueueItem< T*temp=orig.hea d;temp;temp=tem p->next)
* * * * * *{
* * * * * * * * * *push(temp->value);
* * * * * *}
* *}
* *Queue& operator=(Queue & orig)
* *{
* * * * * *head =0;
* * * * * *tail =0;
* * * * * *for(QueueItem< T*temp=orig.hea d;temp;temp=tem p->next)
* * * * * *{
* * * * * * * * * *push(temp->value);
* * * * * *}
* * * * * *return *this;
* *}
* *~Queue()
* *{
* * * * * *while (head)
* * * * * *{
* * * * * * * * * *cout<<"In~Queu e";
* * * * * * * * * *pop();
* * * * * * * * * *}
* *}
* *void pop();
* *void push(T item);
* *bool empty(){
* * * * * *if (head==0)
* * * * * * * * * *return 1;
* * * * * *return 0;
* *}
};
template <typename Tvoid Queue<T>::push( T item)
{
* *if(empty())
* *{
* * * * * *head = new QueueItem<T>(it em);
* * * * * *tail=head;
* *}
* *else
* *{
* * * * * *QueueItem<T*te mp;
* * * * * *temp = new QueueItem<T>(it em);
* * * * * *tail->next=temp;
* * * * * *tail=temp;
* *}
}
template <typename Tvoid Queue<T>::pop()
{
* *if(!empty())
* *{
* * * * * *QueueItem<T*te mp;
* * * * * *temp=head;
* * * * * *head = head->next;
* * * * * *cout<< "pop a value of "<<temp->value<<endl;
* * * * * *delete temp;
* *}
* *else
* *{
* * * * * *cerr<<"the Queue is empty, so cannot call pop function"<<endl ;
* *}
}
int main()
{
* *Queue<intorig_ queue;
* *for(int i=0; i<8; i++)
* * * * * *orig_queue.pus h(i);
* *Queue<intcopy_ queue;
* *copy_queue(ori g_queue);//this line has compile error

This syntax actually means to invoke the [non-existent] operator() for
the object called 'copy_queue' with 'orig_queue' as argument. *Did you
actually mean to do

* * *Queue<intcopy_ queue(orig_queu e);

?
* *return 0;
}
and get the compiling error :
no match for call to ‘(Queue<int>) (Queue<int>&)’ * * *Queue * Queue.cc * * * *line
103 * * * *1214317008414 * 99
for the line copy_queue(orig _queue): line
Could you please help me out for this problem? Thanks

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2441
by: Luc Dal | last post by:
Hello, I've serious problem using ASP under WindowsXP sp2. I get the following reply (sorry it's in french) Erreur de compilation Microsoft VBScript error '800a0401' Fin d'instruction attendue /iisHelp/common/500-100.asp, line 11
7
5087
by: Vaca Louca | last post by:
Hello, My setup: Debian sarge on dual Pentium 4. g++ 3.3.5-3. (the other system is Windows XP with MS Visual Studio .NET 2003) I have an auto_array<T> template (based on a template taken from the Corona project hosted at SourceForge) which basically wants to implement std::auto_ptr<T> semantics for an array.
134
7919
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you can inadvertently re-use an variable used in an enclosing context when you don't intend to, or
5
8091
by: Dmitriy Lapshin [C# / .NET MVP] | last post by:
Hi all, I think the VB .NET compiler should at least issue a warning when a function does not return value. C# and C++ compilers treat this situation as an error and I believe this is the right thing to do. And I wonder why VB .NET keeps silence and makes such function return some default value instead. Isn't it error-prone? -- Dmitriy Lapshin
0
3369
by: gui.besse | last post by:
It seems that we can't bind a collection of instance of different type. Let's have an example: // My POCO public interface ITest { string Name { get;set;} } public class A : ITest {
1
2302
by: dasayu | last post by:
Hi, I have a custom object called gridWidget. I am consistantly getting an error in FireFox when I click on an href, which calls a function defined on the object. The generated link looks similar to: javascript:gridWidget.editColumn(3, 3, 'PDDSectionForm', 'pdd_link', ..) The above works fine in IE.
3
3638
by: JToe | last post by:
Hi, I have a sql statement which is as follows:- INSERT INTO expense(Jan) SELECT sum(ECFAmount) FROM Transaction WHERE Date BETWEEN (#01/01/2007#) AND (#01/31/2007# ) When i execute the above, I have an error like this >> java.sql.SQLException: Too few parameters. Expected 1. can someone pls suggest or advise me what can be the problem?
18
11151
by: ana10192000 | last post by:
VB6.0 Private dbParts as Database Private dbParts as Recordset guys help, i can't execute my program compiler error says: " user-defined type not defined " i'm not much a knowledgable programmer, i'm still just a student, do explain it in a little bit detailed statements. thanks!
1
2357
by: patelxxx | last post by:
Hi Guy's, I'm getting the error: "Username or password did not match" BEFORE I even enter a username and password, can someone help? 1) The site I'm accessing is: http://www.valuemapping.co.uk/VMSE/ 2) Then I click/select the following application: "VMSE Reporting" and get the above error. The CGI script for this is:
0
9684
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
9530
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
10459
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
10236
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...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.