I have a BaseClass, which everything inherits in one way or another, and what I want to do, is whenever one of the classes that inherits this BaseClass it adds a std::vector<instanced class> into the list of classes that BaseClass has, and whenever a class tries to add an instance into this list, and that class already has an instance of itself in the list, add it to a sublist inside the class list.

I think this would be better expressed into code:

std::vector< std::vector<void*> > classInstances;
	BaseClass(std::string className)
	{
		
		if(already has class with that className)
                        find the vector that has the class in it, and
                        add the newly instanced class to that vector; 
                else
                        classes.push_back(std::vector<class being instanced>)
	}

	void* getClassHandle(std::string className)
	{
		this is for getting the class that has the classname that
                is equal to the className paramater; no idea how to do this either
	}

All and any help will and would be appreciated :)
Thanks in advance

This is what I have come up with so far:

void* BaseClass::getClassHandle(std::string className)
{
	for(int i=0;i<classes.size();i++)
	{
		for(int i=0;i<classes[i].size();i++)
		{
			std::vector<void*> val = classes[i];
			for(int i=0;i<val.size();i++)
			{
				if(val[i].name == className)
					return val[i];
			}
		}
	}
}

Would this work?

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.