My c++ code should work, but UCLASS and class is throwing errors that can't be fixed

Your class should deriver from AActor or UObject. Also it should include some generated headers and so on.
It’s kind a boring task to explain every aspect here, so the best solution for you should be making new class from Unreal Editor:

  1. Start Unreal Editor.
  2. In Content Browser open C++ Classes.
  3. Choose folder you want your newly created class to be in.
  4. Right click on free space and choose “New C++ Class…”
  5. In a Choose Parent Class window click on checkbox in right top corner called “Show All Classes”
  6. Type “UObject” in search field to be sure you are right. Or just:
  7. Select Object in search results and click Next button.
  8. Name your class and check desired location.

As a result, you’ll get already compiled, correctly written class.

Like this one:

MyNewObject.h:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Object.h"
#include "MyNewObject.generated.h"

/**
 * 
 */
UCLASS()
class MYGAME_API UMyNewObject : public UObject
{
	GENERATED_BODY()

};

MyNewObject.cpp:

// Fill out your copyright notice in the Description page of Project Settings.

#include "MyGame.h"
#include "MyNewObject.h"