By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

Error with template syntax, please help

P: n/a
//
// The code below produces the following compiler error message.
// I don't know enough about the correct syntax to fix this problem.
// What am I doing wrong? Thanks.
//
// test.cpp(29) : error C2244: 'MapAny2Any<Type1,Type2>::find' : unable to resolve function overload
//
//
//
#include <map>

template <class Type1, class Type2>
class MapAny2Any {
private:
std::map<Type1, Type2> AnyMap;
public:
void insert(Type1& T1, Type2& T2);
Type2* find(Type2& T1);
};

template <class Type1, class Type2>
inline void MapAny2Any<Type1, Type2>::insert(Type1& T1, Type2& T2)
{
insert(std::make_pair(T1, T2));
}

template <class Type1, class Type2>
inline Type2* MapAny2Any<Type1, Type2>::find(Type1& T1)
{
std::map<Type1, Type2>::iterator Pos;
Pos = AnyMap.find(T1);
if (Pos != AnyMap.end())
return &Pos->second;
return NULL;
}

int main()
{
return 0;
}


Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Peter Olcott wrote in
news:C7*********************@bgtnsc05-news.ops.worldnet.att.net:
//
// The code below produces the following compiler error message.
// I don't know enough about the correct syntax to fix this problem.
// What am I doing wrong? Thanks.
//
// test.cpp(29) : error C2244: 'MapAny2Any<Type1,Type2>::find' :
unable to resolve function overload //
//
// Type2* find(Type2& T1); inline Type2* MapAny2Any<Type1, Type2>::find(Type1& T1)


Note the different argument types.

HTH.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 19 '05 #2

P: n/a
> > Type2* find(Type2& T1);
inline Type2* MapAny2Any<Type1, Type2>::find(Type1& T1)


Note the different argument types.

HTH.

Rob.


That did it, thanks.
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.