# TSubClassOf function does not take 1 arguments

**URL:** <https://forums.unrealengine.com/t/tsubclassof-function-does-not-take-1-arguments/468308>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [July 17, 2020, 5:21pm UTC](https://forums.unrealengine.com/t/tsubclassof-function-does-not-take-1-arguments/468308 "2020-07-17T17:21:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Norton](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alexander\_Norton](https://forums.unrealengine.com/u/Alexander_Norton)\
**Post date:** [July 17, 2020, 5:21pm UTC](https://forums.unrealengine.com/t/tsubclassof-function-does-not-take-1-arguments/468308/1 "2020-07-17T17:21:33Z")

</div>

Characters in my game can execute 2 special abilities. A component ‘SPlayerAbilityComponent’ attaches to the character to enable this. I can then select their ability from blueprints since it’s a TSubclassOf:  
SPlayerAbilityComponent.h:

```
UPROPERTY(EditAnywhere)
TSubclassOf<class USBaseAbility> AbilityOneClass;

UPROPERTY(EditAnywhere)
TSubclassOf<class USBaseAbility> AbilityTwoClass;

USBaseAbility* AbilityOne;
ASCharacter* OwnedCharacter;

```

The base class is USBaseAbility and the specific abilities inherit it. For example, USBoostAbility inherits USBaseAbility.  
The SPlayerAbilityComponent.cpp creates a new object from the class variable and provides the USBoostAbility with the character when it’s used:

```
void USPlayerAbilityComponent::UseAbilityOne()
{
	AbilityOne = NewObject<USBoostAbility>(this, USBoostAbility::StaticClass());
	AbilityOne->Use(OwnedCharacter);
	UE_LOG(LogTemp, Warning, TEXT("Ability one used."));

}

```

But I’m getting an error:  
‘USBaseAbility::Use’: function does not take 1 arguments.

syntax error: identifier ‘ASCharacter’.

SBaseAbility.h has a Use function:

```
void Use(ASCharacter* OwnedCharacter);

```

and its implementation:

```
void USBaseAbility::Use(ASCharacter* OwnedCharacter)
{
	// Execute the ability functionality.
	if (!CanUse)
	{
		// Must wait for cooldown.
		UE_LOG(LogTemp, Warning, TEXT("WAIT FOR COOLDOWN"));
		return;
	}

	// Execute the ability and set a timer.
	ExecuteAbility();

```

I’m providing it with a character argument but it seems to fail.  
Any ideas why?

Thank you very much.

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [July 17, 2020, 6:29pm UTC](https://forums.unrealengine.com/t/tsubclassof-function-does-not-take-1-arguments/468308/2 "2020-07-17T18:29:28Z")

</div>

Did you include all necessary headers, like the “SCharacter.h” in your component?

---

<div class="post-metadata">

**Author:** ![Alexander\_Norton](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alexander\_Norton](https://forums.unrealengine.com/u/Alexander_Norton)\
**Post date:** [July 17, 2020, 6:54pm UTC](https://forums.unrealengine.com/t/tsubclassof-function-does-not-take-1-arguments/468308/3 "2020-07-17T18:54:38Z")

</div>

I did indeed. SCharacter.h, SBaseAbility.h and SBoostAbility.h are all included in the component. Also included in the SBaseAbility.cpp.

It executes the Use function with no problem when no arguments are required. But when I require an SCharacter\* argument it fails.

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [July 17, 2020, 7:02pm UTC](https://forums.unrealengine.com/t/tsubclassof-function-does-not-take-1-arguments/468308/4 "2020-07-17T19:02:33Z")

</div>

> It executes the Use function with no problem when no arguments are required. But when I require an SCharacter\* argument it fails.

So, you have two Use functions, one with no args and another with args? Are they both accessible?

---

<div class="post-metadata">

**Author:** ![Alexander\_Norton](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alexander\_Norton](https://forums.unrealengine.com/u/Alexander_Norton)\
**Post date:** [July 17, 2020, 7:35pm UTC](https://forums.unrealengine.com/t/tsubclassof-function-does-not-take-1-arguments/468308/5 "2020-07-17T19:35:55Z")

</div>

No just one Use function but I’m removing the ‘ASCharacter\* OwnedCharacter’ argument to test it out and it works

---

<div class="post-metadata">

**Author:** ![EvilCleric](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EvilCleric](https://forums.unrealengine.com/u/EvilCleric)\
**Post date:** [July 17, 2020, 8:41pm UTC](https://forums.unrealengine.com/t/tsubclassof-function-does-not-take-1-arguments/468308/6 "2020-07-17T20:41:32Z")

</div>

> SCharacter.h, SBaseAbility.h and SBoostAbility.h are all included in the component. Also included in the SBaseAbility.cpp.

Did you include all those both in the .h and .cpp file? If so, then that could be the source of the problem. Remove those includes from the header file and use forward declarations instead.

---

<div class="post-metadata">

**Author:** ![Alexander\_Norton](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alexander\_Norton](https://forums.unrealengine.com/u/Alexander_Norton)\
**Post date:** [July 17, 2020, 11:28pm UTC](https://forums.unrealengine.com/t/tsubclassof-function-does-not-take-1-arguments/468308/7 "2020-07-17T23:28:19Z")

</div>

Yup, I was including SCharacter.h in my SBoostAbility.h file. And I was referencing it incorrectly in the SBaseAbility.cpp (Supposed to be ‘Player/SCharacter.h’ not just ‘SCharacter.h’. Would still be lost without your input. Thanks so much!
