Archived

This topic is now archived and is closed to further replies.

using this pointer...

This topic is 6363 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

    
class BaseMessageIndex
{
public:

protected:
	void RegisterID(MESSAGEID messageid)
	{
//		IDRegistry.insert((unsigned char)messageid,this);
	}

	void RegisterString(string &messagestring)
	{
		StringRegistry.insert(messagestring,this);
	}

	typedef map<unsigned char,	BaseMessageIndex*> IDRegistryMap;
	typedef map<string,			BaseMessageIndex*> StringRegistryMap;
	static IDRegistryMap		IDRegistry;
	static StringRegistryMap	StringRegistry;
};
    
When doing an insert with the ''this'' pointer I get : No constructor could take the source type, or constructor overload resolution was ambiguous Any hints on what this means? thanks chris

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

try giving your base class a default constructor, see if that helps.

There are certain "guidelines" that make a "nice" class, which is what STL expects when you start using your own classes/data types for its containers.

1)default ctor
2)copy ctor

and I can''t remember the other 2 off the top of my head...will post in the am.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Actually, I belive that the problem is that the "insert" method of maps actually takes a parameter of type "pair". This is also typedefed to be value_type.
So, I think that the following code will solve your problem:

    
void RegisterID(MESSAGEID messageid)
{
IDRegistry.insert(IDRegistryMap::value_type((unsigned char)messageid,this));
}
void RegisterString(string &messagestring)
{
StringRegistry.insert(StringRegistryMap::value_type(messagestring, this));
}


Hope this helps.

...Syzygy

Share this post


Link to post
Share on other sites
Syzygy, I think your right....Thats code does make the error go away. It''ll take a bit more time to create the test but I''m optimistic. Thank you very much... I''ll add that to my ''things to learn list''...

gimp

Share this post


Link to post
Share on other sites