C++ Struct that contains a map of itself
问题 Simple question: How do I get this to work? struct A { double whatever; std::unordered_map<std::string, A> mapToMoreA; } g++ error: std::pair<_T1, _T2>::second has incomplete type As far as I understand, when instantiating the map, the compiler needs to know the size of A, but it doesn't know this because the map is declared in A's declaration, so is the only way to get around this to use pointers to A (don't feel like doing that)? 回答1: Most of the time it will depend on the container