C++ Template Classes Circular Dependency Problem
- by TomWij
We have two classes:
template<typename T, typename Size, typename Stack, typename Sparse>
class Matrix
and
template<typename T, typename Size>
class Iterator
Matrix should be able to return begin and end iterators and Iterator will keep a referrence to the Matrix to access the elements via it's interface. We don't want Iterator to depend on the internal storage of the Matrix to prevent coupling. How can we solve this cyclic dependency problem?
(The internal Storage class has the same template parameters as the Matrix class and the same access procedures as the Matrix itself)