Consider the following code snippet, where the first line serves only as forward declaration
class A;
followed by defining new class
[As supplemental instruction to Barry's answer]
According to the standard (C++17), only std::vector, std::list and std::forward_list could be used with incomplete type when instantiating.
§23.3.11.1/3 Class template vector overview [vector.overview]:
An incomplete type
Tmay be used when instantiatingvectorif the allocator satisfies the allocator completeness requirements [allocator.requirements.completeness].Tshall be complete before any member of the resulting specialization ofvectoris referenced.
§23.3.9.1/4 Class template forward_list overview [forwardlist.overview]:
An incomplete type
Tmay be used when instantiatingforward_listif the allocator satisfies the allocator completeness requirements [allocator.requirements.completeness].Tshall be complete before any member of the resulting specialization offorward_listis referenced.
§23.3.10.1/3 Class template list overview [list.overview]:
An incomplete type
Tmay be used when instantiatinglistif the allocator satisfies the allocator completeness requirements [allocator.requirements.completeness].Tshall be complete before any member of the resulting specialization oflistis referenced.