If a structure is used only inside a class, and especially as a private member, then of course it is better to encapsulate its declaration into a class definition.
If you want to use a structure besides class definition, then it is better to declare it separately from the class.
Note that inside a class the structure declaration itself may have a public access class, whereas a data member of a class with this type may have a private access class.
class A{ public: struct Tdata{ std::string name; std::string second_name; //.... }; private: Tdata data; //... };
It all depends on how you intend to use the class and structure, what interface you want to provide to users of the class and structure.
In addition, if the definition of a nested structure itself is not used in a class, then the structure can be defined outside the class, and in the class itself only to declare it. for example
class A{ public: struct TData; private: Tdata *data; //... }; struct A::Tdata{ std::string name; std::string second_name; //.... };