I don’t have access to the editor and my project right now, so can’t check to be 100% sure, but I think you’ll want to change the UPROPERTY in class B to look as follows:
UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="X") TSubclassOf<ClassA> a
The reason for this is that Blueprints you create in the editor essentially are classes themselves, and not objects. With the code you previously had, you would be able to select an instance of the blueprint if you had dragged that blueprint into some level (which would only be possible if it were Placeable though).
When using TSubclassOf<ClassA>, you will also have the option to select the C++ class ‘‘ClassA’’ itself, in addition to any blueprints with ClassA as a parent. If this is undesired (for example because you use the blueprints to assign values to various properties, and the C++ class does not have correct values assigned by itself), you can use the HideDropdown specifier in the UCLASS() macro of ClassA.
One last tip: If your ClassA is purely intended to contain data and it is not necessary to ever use the full functionality of Blueprint graphs in objects of ClassA, I would recommend having ClassA extend UDataAsset instead of UObject. Then, assets are created in the editor through Miscellaneous -> Data Asset instead of through the Blueprint menu options, and then you’ll want to keep the UPROPERTY as it is now (a pointer instead of a TSubclassOf).