C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 16th, 2003, 12:02 PM
shim shim is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 9 shim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
'function' : cannot convert parameter number from 'type1' to 'type2'

This snapshot is from Visual C++ 6.0

Any help ????????????????
------------------------------------------------------------------------

#include <iostream>
#include <queue>
#include <list>

using namespace std;

int main()
{
int myint = 5;
queue< list<int> > h;

h.push(myint); //the following error is due to this line

return 0;
}

ompiling...
1.cpp
E:\1\1.cpp(13) : error C2664: 'push' : cannot convert parameter 1 from 'int' to 'const class std::list<int,class std::allocator<int> > &'
Reason: cannot convert from 'int' to 'const class std::list<int,class std::allocator<int> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

1.obj - 1 error(s), 0 warning(s)

Reply With Quote
  #2  
Old June 16th, 2003, 02:42 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is online now
Contributing User
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 3,833 dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 4 h 11 m 7 sec
Reputation Power: 446
I haven't played with STL yet, but it looks like you created h as a queue of lists, so the queue's push method is expecting a list instead of the int that you are feeding it.

Reply With Quote
  #3  
Old June 16th, 2003, 06:29 PM
shim shim is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 9 shim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The documentation of STL says that 'queue' class provides simpler interface by encapsulating 'list' class. i.e. its push() and pop() functions internally calls push_front() etc functions of list class.
We only have to supply the integer (or the type whose list is created).

Reply With Quote
  #4  
Old June 16th, 2003, 07:09 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is online now
Contributing User
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 3,833 dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 4 h 11 m 7 sec
Reputation Power: 446
Quote:
Originally posted by shim
The documentation of STL says that 'queue' class provides simpler interface by encapsulating 'list' class. i.e. its push() and pop() functions internally calls push_front() etc functions of list class.
We only have to supply the integer (or the type whose list is created).

So then are you saying that you should have written your declaration as:

queue<int> h;

?


EDIT:

In Google'ing on 'STL queue', I found this code fragment:
Code:
  list<int> myList;
      
    for(int j=1;j<5;++j)myList.push_back(j);

   queue<int, list<int> > myQueue(myList);

Would that queue declaration cover what you are trying to do?

Last edited by dwise1_aol : June 16th, 2003 at 07:22 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > 'function' : cannot convert parameter number from 'type1' to 'type2'


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway