Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > ambiguous call ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 9759 of 9938
Post > Topic >>

ambiguous call to overloaded function

by Ruki <waruqi@[EMAIL PROTECTED] > Jun 30, 2008 at 09:01 AM

{ This article is multi-posted to [comp.lang.c++]. -mod }

I want to overload function to swap two others types, for example,
type<T>, T* and so on,
but I can't compile the following code at VC 6.0.

The compiler says :
error C2667: 'swap' : none of 2 overload have a best conversion
error C2668: 'swap' : ambiguous call to overloaded function
---------------------------------------------------------------------------­----------------------------------
template < typename T >
void swap(T &lhs, T &rhs)
{
         // do some thing



}


template < typename T >
void swap(T *lhs, T *rhs)
{
         // do some thing


}


template < typename T >
struct type{};

template < typename T >
void swap(type<T> &lhs, type<T> &rhs)
{
         // do some thing


}


int main()
{
         int *p1,*p2;
         type<int> t1, t2;
         swap(t1, t2);
         swap(p1, p2);



-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 4 Posts in Topic:
ambiguous call to overloaded function
Ruki <waruqi@[EMAIL PR  2008-06-30 09:01:52 
Re: ambiguous call to overloaded function
alasham.said@[EMAIL PROTE  2008-07-01 19:44:41 
Re: ambiguous call to overloaded function
Arindam <arindam.muker  2008-07-01 19:52:27 
Re: ambiguous call to overloaded function
Ruki <waruqi@[EMAIL PR  2008-07-05 04:58:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 27 20:48:10 CDT 2008.