# GENERATED\_BODY vs GENERATED\_UCLASS\_BODY

**URL:** <https://forums.unrealengine.com/t/generated-body-vs-generated-uclass-body/322489>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [June 20, 2015, 10:50pm UTC](https://forums.unrealengine.com/t/generated-body-vs-generated-uclass-body/322489 "2015-06-20T22:50:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ubi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ubi](https://forums.unrealengine.com/u/ubi)\
**Post date:** [June 20, 2015, 10:50pm UTC](https://forums.unrealengine.com/t/generated-body-vs-generated-uclass-body/322489/1 "2015-06-20T22:50:09Z")

</div>

I am learning C++ version of the FPS in UE following this: [A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums](https://wiki.unrealengine.com/First_Person_Shooter_C%2B%2B_Tutorial)

When I created a new class all the time there is GENERATED\_BODY and the tutorial say I have to override the constructor and use `AFPSGameMode(const FObjectInitializer& ObjectInitializer)` but the compiler give me an error because I can’t redeclare the constructor.

The get around of this is use GENERATED\_UCLASS\_BODY and then my constructor have the correct parameters but I dont know if I am doing it right.

I am new in UE so I really want to learn what I should use.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8e2766aa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8e2766aa](https://forums.unrealengine.com/u/anonymous_user_8e2766aa)\
**Post date:** [June 23, 2015, 6:50am UTC](https://forums.unrealengine.com/t/generated-body-vs-generated-uclass-body/322489/2 "2015-06-23T06:50:37Z")

</div>

Hello, ubi

Please note that with `GENERATED_BODY()`, a constructor is no longer necessary for each class (however, if you need a constructor, you can declare and define it as usual).  
The other difference is that, in comparison to `GENERATED_UCLASS_BODY()`, `GENERATED_BODY()` doesn’t have the `public` specifier in it, so any class members that are declared after it are `private` by default (you can explicitly declare them as `public`).  
In your situation, please make sure that you have your constructor declared and defined correctly:

```
//.h file
//...
	GENERATED_BODY()
	
public:
	AFPSGameMode(const class FObjectInitializer& ObjectInitializer);

// .cpp file
AFPSGameMode::AFPSGameMode(const class FObjectInitializer& ObjectInitializer)
{
       // constructor functionality
}

```

Hope this helped!

Have a great day!

---

<div class="post-metadata">

**Author:** ![Jibberish](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jibberish](https://forums.unrealengine.com/u/Jibberish)\
**Post date:** [July 5, 2015, 4:39am UTC](https://forums.unrealengine.com/t/generated-body-vs-generated-uclass-body/322489/3 "2015-07-05T04:39:09Z")

</div>

I’m clear on the public scope issue, my question is not about that. Being new to UE4 myself, does this mean that we should never use GENERATED\_ **UCLASS** \_BODY going forward? I found the “recommendation” that it not be used anymore in the 4.6 release notes, but I guess it’s not officially deprecated?

I’m experiencing the same behavior described in the OP’s question, because if I use GENERATED\_BODY like in my code below, in the way you describe, I still get errors with my (truncated) code.

**CODE**

```
// .h
 #pragma once
 #include "GameFramework/Character.h"
 #include "UETestCharacter.generated.h"
 
 UCLASS(config=Game)
 class AUETestCharacter : public ACharacter
 {
     GENERATED_BODY()
 
 public:
      AUETestCharacter(const class FObjectInitializer& ObjectInitializer);
 }...
 
 // .cpp   
 #include "UETestCharacter.h"
 #include "UETestCharacter.h"
 #include "BatteryPickup.h"
 
 AUETestCharacter::AUETestCharacter(const class FObjectInitializer &ObjectInitializer)
 {
         // constructor functionality
 }...

```

**ERRORS**

```
Error	1	error code: OtherCompilationError (5)	C:\Users\\Documents\Unreal Projects\UETest\Intermediate\ProjectFiles\Error	UETest
Error	2	error MSB3073: The command ""C:\Program Files\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat" UETestEditor Win64 Development "C:\Users\\Documents\Unreal Projects\UETest\UETest.uproject" -rocket" exited with code -1.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets	38	5	UETest
	3	IntelliSense: no instance of constructor "AUETestCharacter::AUETestCharacter" matches the argument list	c:\Users\\Documents\Unreal Projects\UETest\Source\UETest\UETestCharacter.h	9	2	UETest

```

Many thanks!

---

<div class="post-metadata">

**Author:** ![Jibberish](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jibberish](https://forums.unrealengine.com/u/Jibberish)\
**Post date:** [July 11, 2015, 1:31am UTC](https://forums.unrealengine.com/t/generated-body-vs-generated-uclass-body/322489/4 "2015-07-11T01:31:10Z")

</div>

Never mind, it works now. I actually had a syntax error.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_af11fb2b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_af11fb2b](https://forums.unrealengine.com/u/anonymous_user_af11fb2b)\
**Post date:** [March 27, 2016, 9:11am UTC](https://forums.unrealengine.com/t/generated-body-vs-generated-uclass-body/322489/5 "2016-03-27T09:11:16Z")

</div>

This very very helped, I couldn’t understand errors that I had, and difference between GENERATED\_BODY and GENERATED\_UCLASS\_BODY regarding constructor “(const class FObjectInitializer& ObjectInitializer)” helped me a lot. It’s my third day learning UE4. Thank you!
