What is the syntax for using super?

Hey, I am used to programming in UE3, and just started getting into UE4.
However, while I’m recognizing a lot, I am also confused by some of the new syntaxes for functions (are they called constructors now? Or is that something else?)

I am currently simply trying to call a super in a function so that I can modify it while keeping the parent functionality.

This is what I got so far:

Parent

// Sets default values
ABrawler_Character_Base::ABrawler_Character_Base()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

Child:

// Sets default values
ABrawler_Character_Player::ABrawler_Character_Base()
{
	Super::ABrawler_Character_Base();

}

But I am obviously getting a ton of syntax errors, please help?
What am I missing?

Also, how do I know my class is correctly parented? I assume the wizard would sort it out, is it this stuff:

class BRAWLER_API ABrawler_Character_Player : public ABrawler_Character_Base
{
	GENERATED_BODY()
	
	
	
	
};

Try declaring the inherited function in the header of the child class as

virtual void ABrawler_Character_Base() override;

The keyword being override. If that doesn’t solve it we may need a sample of your compiler errors.

You can’t override the constructor like that. Instead, ABrawler_Character_Player will need its own constructor and override any values different from the base/parent class’ settings in that one.

The syntax for a constructor calling the parent class’ constructor looks like this:

ABrawler_Character_Player::ABrawler_Character_Player(string exampleParameter) :
{
   // settings for ABrawlerPlayerCharacter_Base and all its children
}

ABrawler_Character_Player::ABrawler_Character_Player(string exampleParameter) :
	ABrawlerPlayerCharacter_Base(exampleParameter)
{    
   // settings for ABrawler_Character_Player
}

For functions, you need to use the virtual and override keywords as described by getnamo and then, yes, call it as Super::Function_Name().

Either way, every function defined in the .cpp file needs to be declared in the corresponding header file (there are exceptions but they’re not important here). I mention this because your class example doesn’t contain a declaration of the constructor. Forgetting this will also result in some syntax errors.

Cheers, now I know about headers and how to do supers.

As for overriding the constructor, I tried doing:

ABrawler_Character_Player::ABrawler_Character_Player() 
ABrawler_Character_Base()
{


}

But I get these syntax errors:

Error	1	error C3646: 'ABrawler_Character_Base' : unknown override specifier	C:\Users\Gray\Desktop\Brawler\Project Files\Brawler\Source\Brawler\Brawler_Character_Player.cpp	8	1	Brawler
Error	2	error C2091: function returns function	C:\Users\Gray\Desktop\Brawler\Project Files\Brawler\Source\Brawler\Brawler_Character_Player.cpp	9	1	Brawler
Error	3	error : Failed to produce item: C:\Users\Gray\Desktop\Brawler\Project Files\Brawler\Binaries\Win64\UE4Editor-Brawler.dll	C:\Users\Gray\Desktop\Brawler\Project Files\Brawler\Intermediate\ProjectFiles\ERROR	Brawler
Error	4	error MSB3073: The command ""C:\Program Files\Epic Games\4.9\Engine\Build\BatchFiles\Build.bat" BrawlerEditor Win64 Development "C:\Users\Gray\Desktop\Brawler\Project Files\Brawler\Brawler.uproject" -rocket -waitmutex" exited with code -1.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets	38	5	Brawler
	5	IntelliSense: expected a '{'	c:\Users\Gray\Desktop\Brawler\Project Files\Brawler\Source\Brawler\Brawler_Character_Player.cpp	8	1	Brawler

You need a colon before calling the parent constructor.

ABrawler_Character_Player::ABrawler_Character_Player() 
  : ABrawler_Character_Base()
 {
  }

I tried that too first, but then it gave me an error that ABrawler_Character player already has a body.

How did you declare the constructor in the header file?

It sounds like you already defined the empty constructor like this:

ABrawler_Character_Player() {};

A lot of the time you don’t need any special code in the constructor, so this saves you some code in the cpp file.

However, if you want to change the constructor behavior in the cpp file, you need to leave out the curly brackets. Otherwise you will get an error like the one you described.

ABrawler_Character_Player();