It is very difficult for me to formulate what I need - sorry - so please make some changes to the question if you think it might make it better understandable for others.
I will create a short example of what I would like to do:
I have a class that has a static function and an object member:
class A
{
public:
Member x;
static std::string getName()
{
return "Name of A";
}
};
This is the definition of Member:
class Member
{
public:
void printSomething()
{
cout<<"I am a member of "<<ClassWhereIAmAMember::getName()<<endl; //what can I use instead of ClassWhereIAmAMember??
}
};
My final result should be that I can use Member like this:
int main()
{
A a;
a.x.printSomething();
}
And the final result should be obviously
I am a member of Name of A
I know I could change Member to a template class and declaring it in A like Member<A> x but I would like to keep this as simple and as clean as possible. And in my opininion the compiler should be able to deduce it from the context.
Unfortunately I can't think of any method/paradigm how to accomplish this. Is there a way?