Language: C++

#include<iostream>
#include<list>
#include<vector>
#include<string>
enum {
	 RootParentID = -1
};
class tree {
private:
	struct {
		int id;
		int parent;
		std::vector<int>children;
	};
public:
	std::vector<tree>nodes;
	tree(int n);
	void addChild(int id, int x);
	int depth(int id);
	std::string printType(int id);
	void printInfo(int id);
	~tree();
};
tree::tree(int n) {
	nodes.resize(n);
	for (int i = 0; i < n; ++i) {
		nodes[i].id = i;
		nodes[i].parent = -1;
	}

}
tree::~tree() {
}
void tree::addChild(int id, int x)
{
	nodes[id].children.push_back(x);
	nodes[x].parent = id;
}

int tree::depth(int id)
{
	int x = id;
	int cnt = 0;
	while (RootParentID != nodes[x].parent)
	{
		x = nodes[x].parent;
		cnt++;
	}
	return cnt;
}
std::string tree::printType(int id)
{
	if (RootParentID == nodes[id].parent)
		return "root";
	else if (nodes[id].children.size() == 0)
		return "leaf";
	else return "internal node";
}
void tree:: printInfo(int id)
{
	printf("node %d: parent = %d, depth = %d, %s, ", id, nodes[id].parent, depth(id), printType(id));
	printf("[");
	for (int i = 0; i < nodes[id].children.size(); i++)
	{
		printf("%d", nodes[id].children[i]);
		if (i != nodes[id].children.size() - 1)
			printf(", ");
	}
	printf("]\n");
}
int main(void) {
	std::ios_base::sync_with_stdio(false);
	int n;
	std::cin >> n;
	tree Tree(n);
	for (int i = 0; i < n; i++)
	{
		int id, k;
	std::cin >> id >> k;
		for (int j = 0; j < k; j++)
		{
			int child;
			std::cin >> child;
			Tree.addChild(id, child);
		}
	}
	for (int i = 0; i < n; i++) {
		Tree.printInfo(i);
	}
	Tree.~tree();
		//system("pause");
	return 0;
}

Compiler output:
a.cc:13:33: error: member 'std::vector<int> tree::<unnamed struct>::children' with constructor not allowed in anonymous aggregate
   13 |                 std::vector<int>children;
      |                                 ^~~~~~~~
a.cc:13:33: error: member 'std::vector<int> tree::<unnamed struct>::children' with destructor not allowed in anonymous aggregate
a.cc:13:33: error: member 'std::vector<int> tree::<unnamed struct>::children' with copy assignment operator not allowed in anonymous aggregate
In file included from /usr/include/c++/14/bits/alloc_traits.h:33,
                 from /usr/include/c++/14/ext/alloc_traits.h:34,
                 from /usr/include/c++/14/bits/basic_string.h:39,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = tree; _Args = {}]':
/usr/include/c++/14/bits/stl_uninitialized.h:643:18:   required from 'static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = tree*; _Size = long unsigned int; bool _TrivialValueType = false]'
  643 |                 std::_Construct(std::__addressof(*__cur));
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:712:20:   required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = tree*; _Size = long unsigned int]'
  710 |       return __uninitialized_default_n_1<__is_trivial(_ValueType)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  711 |                                          && __can_fill>::
      |                                          ~~~~~~~~~~~~~~~~
  712 |         __uninit_default_n(__first, __n);
      |         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:779:44:   required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = tree*; _Size = long unsigned int; _Tp = tree]'
  779 |     { return std::__uninitialized_default_n(__first, __n); }
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:821:35:   required from 'void std::vector<_Tp, _Alloc>::_M_default_append(size_type) [with _Tp = tree; _Alloc = std::allocator<tree>; size_type = long unsigned int]'
  821 |                 std::__uninitialized_default_n_a(this->_M_impl._M_finish,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
  822 |                                                  __n, _M_get_Tp_allocator());
      |                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1016:4:   required from 'void std::vector<_Tp, _Alloc>::resize(size_type) [with _Tp = tree; _Alloc = std::allocator<tree>; size_type = long unsigned int]'
 1016 |           _M_default_append(__new_size - size());
      |           ^~~~~~~~~~~~~~~~~
a.cc:25:14:   required from here
   25 |         nodes.resize(n);
      |         ~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_construct.h:119:7: error: no matching function for call to 'tree::tree()'
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:24:1: note: candidate: 'tree::tree(int)'
   24 | tree::tree(int n) {
      | ^~~~
a.cc:24:1: note:   candidate expects 1 argument, 0 provided
a.cc:8:7: note: candidate: 'tree::tree(const tree&)'
    8 | class tree {
      |       ^~~~
a.cc:8:7: note:   candidate expects 1 argument, 0 provided