In the simplified code below I am trying within VS to not have an error occur at the typedef statement in that it doesn't recognize B at that statement and will give the error "missing ';' before '<'".
template<class DT>
class A{
typedef B<DT> iterator;
}
template<class DT>
class B{
friend A<DT>;
}
And I understand that inserting a class prototype of B should solve this problem (source: Class prototyping) but I am still finding that VS doesn't recognize that B exists before entering the typedef statement, and will still spit back that same syntax error
class B; //prototype of B
template<class DT>
class A{
typedef B<DT> iterator;
}
template<class DT>
class B{
friend A<DT>;
}
And in the case of switching the arrangement to having B assigned first then A, and changing it to having a class prototype of A, because A is supposed to be a friend of B, but the compiler doesn't know B exists yet. I get the error of having "argument list for class template A is missing".
class A; //prototype of B
template<class DT>
class B{
friend A<DT>;
}`
template<class DT>`
class A{
typedef B<DT> iterator;
}
And looking into that error (source: Argument list for class template is missing) I found you change the statement to taking a '' and adding the statement 'template' above that. Which does solve the inheritance between the two classes, but that causes the methods (within my detailed code) of our class A to be inaccessible when testing the functionality. Any ideas as to how I should go about keeping this inheritance the same but not making class A become purely virtual, non accessible from another source (.cpp)?