what i want to do is when A object enters a new class K it has to exit(deleted from the lists) all of the K(child B and D)s it is in but i get this error just cant figure it out. there is actually a bigger list that lists class K s but i cant reach it by reference(well i can but lots of work not the point)and project has to be circularly dependent
//class A.h
#include some_other_header_circularly_dependent_on_class_B
class B
class A{
public:
string getname(){return name;};
void setWhere(K *a){whereami=a;};
void exit(){
if(whereami!=NULL)
(whereami)->exit(name);//error C2227: left of '->exit' must point to class/struct/union/generic type
};
private:
K* whereami;
string name;
};
//class B.h
#include "A.h"
class K{
//abstract functions
}
class B:public class K{
public:
void enter(A* a){
a->exit();
alist.push_front(a);
a->setWhere(this);
};
void exit(string a){
for(auto it=alist.begin();it!=alist.end();)
if ((*it)->getname()==a)
alist.erase(it);
else it++;
};
private:
list<A*> alist;
};
feel free to suggest solutions or new designs thanks.