Error with template syntax, please help

P

Peter Olcott

//
// 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;
}
 
R

Rob Williscroft

Peter Olcott wrote in
//
// 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top