Hello, and welcome to the community!
If you would be able to post your class code as well, that would help. Also, could you show the output tab, that might have more information on the actual error you are having.
But making an educated guess - is UE opened while you are trying to compile? If yes, and if you are using UE5, try pressing ctrl+alt+F11, it might resolve your issue.