Missing definition error is solved by including only a declaration
<p>Why does including a declaration resolve a missing definition error? This is related to <a href="https://stackoverflow.com/q/36666368/1460794">an earlier question</a>. </p>

<p>In the following set of files I am surprised that a definition is sought for a class that is not used and then when I include only a declaration for the class the program compiles.</p>

<p>I have added comments for the includes that I had to add, but can't understand why they're needed in those particular .cpp files.</p>

<p>A.h</p>

<pre><code>#ifndef A_h
#define A_h

#include &lt;map&gt;

class C;

class A {
public:
    C&amp; add();
    std::map&lt;int,C&gt; Cmap;
    void dosomethingwithC();
};

#endif
</code></pre>

<p>B.h</p>

<pre><code>#ifndef B_h
#define B_h

#include &lt;map&gt;

class A;

class B {
public:
    A&amp; add();
    std::map&lt;int,A&gt; Amap;
};

#endif
</code></pre>

<p>C.h</p>

<pre><code>#ifndef C_h
#define C_h

#include &lt;map&gt;

class B;

class C {
public:
    B&amp; add();
    std::map&lt;int,B&gt; Bmap;
};

#endif
</code></pre>

<p>A.cpp</p>

<pre><code>#include "A.h"

#include "B.h"// Required here, but B isn't used in this file.
              // Without B.h the error is
              // error C2079: 'std::pair&lt;const _Kty,_Ty&gt;::second' uses undefined class 'B'
              // But B.h only includes the declaration, not the definition

#include "C.h"

C&amp; A::add()
{
    auto emplace_results = Cmap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    auto&amp; emplaced_pair = *pair_iterator;
    auto&amp; map_value = emplaced_pair.second;
    return map_value;
}


void A::dosomethingwithC()
{
    Cmap[3].add();
}
</code></pre>

<p>B.cpp</p>

<pre><code>#include "A.h"
#include "B.h"
#include "C.h" // also required here

A&amp; B::add()
{
    auto emplace_results = Amap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    auto&amp; emplaced_pair = *pair_iterator;
    auto&amp; map_value = emplaced_pair.second;
    return map_value;;
}
</code></pre>

<p>C.cpp</p>

<pre><code>#include "A.h" // also required here
#include "B.h"
#include "C.h"

B&amp; C::add()
{
    auto emplace_results = Bmap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    //auto&amp; emplaced_pair = *pair_iterator;
    std::pair&lt;const int,B&gt;&amp; emplaced_pair = *pair_iterator;
    auto&amp; map_value = emplaced_pair.second;
    return map_value;
}
</code></pre>

<p>Main.cpp</p>

<pre><code>#include "A.h"
#include "B.h"
#include "C.h"

int main()
{
    C c;
    auto&amp; emplacedB = c.add();
    auto&amp; emplacedA = emplacedB.add();
    auto&amp; emplacedC = emplacedA.add();
    emplacedC.add();
    return 0;
}
</code></pre>