WORKS:

LLGroupMgrGroupData* LLGroupMgr::getGroupData(const LLUUID& id)
{
	group_map_t::iterator gi = mGroups.find(id);

	if (gi != mGroups.end())
	{
		return gi->second;
	}
	return NULL;
}

DOESN'T WORK:

// static
LLGroupMgrGroupData* LLGroupMgr::getStaticGroupData(const LLUUID& id)
{
	group_map_t::iterator gi = mGroups.find(id);

	if (gi != mGroups.end())
	{
		return gi->second;
	}
	return NULL;
}

Error 1 error C2228: left of '.find' must have class/struct/union
Error 2 error C2228: left of '.end' must have class/struct/union

i get those errors only on the second part, the only diffrences is that the second one is static...

here is the header file:

class LLGroupMgr : public LLSingleton<LLGroupMgr>
{
public:
	LLGroupMgr();
	~LLGroupMgr();

	LLGroupMgrGroupData* getGroupData(const LLUUID& id);
	static LLGroupMgrGroupData* getStaticGroupData(const LLUUID& id);

private:
	typedef std::map<LLUUID, LLGroupMgrGroupData*> group_map_t;
	group_map_t mGroups;
	
};

Please help me solving this out im going crazy !

Recommended Answers

All 2 Replies

I don't know why you are getting this error, I would expect something like 'invalid use of non-static member in static function' error over here. Since getStaticGroupData is a static function of the class and mGroups is a non-static member of the same class and you are not allowed to access non-static members in a static function.

Probably not of interest to the originator after 2 years but answered for anyone else who hits this. It is because mGroups is not static (and hence should not be accessible from the static method). Make mGroups static and this error should go away. Just made a similar mistake myself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.