Proper Inheritance

How do you properly inherince from other classes?
How I would image it would be like this:

#include "ClassName.h"

 AClassName CN;

and from there you can i.e. use CN.GetVariable();

This is what I have done, but everytime or even come close to do something like this, my gasme files crashes the engine nad the project cannot be opened again.

Hope you really can help me out here!

Hello,

Please note that the best and most suitable way to inherit existing class in Unreal Engine 4 would be to add it through the Editor. To do this, please go to File - Add Code to Project, select the class you want to inherit, press Add and wait for the code to compile.
Thus, you’ll get the inheritance-related code generated automatically:

#pragma once

#include "GameFramework/Character.h"
#include "MyCharacter.generated.h"

UCLASS()
class MY_API AMyCharacter : public ACharacter
{
	GENERATED_BODY()
// rest of the code

If you like to learn more about C++ programming in Unreal Engine 4, please go here:

Hope this helped!

Have a great day!