# I have a couple questions about best c++ practices:

**URL:** <https://forums.unrealengine.com/t/i-have-a-couple-questions-about-best-c-practices/435710>\
**Category:** UI\
**Tags:** tick, beginplay, interfaces, unreal-engine, functions, CPP, question\
**Created:** [October 16, 2018, 3:55am UTC](https://forums.unrealengine.com/t/i-have-a-couple-questions-about-best-c-practices/435710 "2018-10-16T03:55:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam54123](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sam54123](https://forums.unrealengine.com/u/Sam54123)\
**Post date:** [October 16, 2018, 3:55am UTC](https://forums.unrealengine.com/t/i-have-a-couple-questions-about-best-c-practices/435710/1 "2018-10-16T03:55:20Z")

</div>

I’m having trouble getting help on the discord server because of my time zone, so here’s a couple questions regarding c++:

1. If I’m trying to store and pass  
around an object that I know  
implements an interface, but I don’t  
know anything else about, should I  
set the variable type to be  
_IInterfaceName_ , TScriptInterface,  
UObject\*, or something else? How  
should I call BlueprintNativeEvent  
functions and other functions in the  
object using the given variable  
type?
2. If I want an optional argument for a  
UFUNCTION that will default to a  
value if un-specified, what should I  
do?
3. Does Tick() run before or after  
BeginPlay()?

If you know the answer to any of these, help would be much appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![sjcobs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sjcobs/32/918649_2.png) [@sjcobs](https://forums.unrealengine.com/u/sjcobs)\
**Post date:** [October 16, 2018, 4:30am UTC](https://forums.unrealengine.com/t/i-have-a-couple-questions-about-best-c-practices/435710/2 "2018-10-16T04:30:41Z")

</div>

1. I would store it as a UObject\*. But inorder to call non interface functions on it you are going to need a reference of the correct type.

2. Assign the default value to the argument inside argument list.

3. After. This would be easy to test by putting a ue log in both and seeing what gets printed first.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![Sam54123](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sam54123](https://forums.unrealengine.com/u/Sam54123)\
**Post date:** [October 16, 2018, 4:36am UTC](https://forums.unrealengine.com/t/i-have-a-couple-questions-about-best-c-practices/435710/3 "2018-10-16T04:36:06Z")

</div>

In the argument list of the header or cpp?

---

<div class="post-metadata">

**Author:** ![sjcobs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sjcobs/32/918649_2.png) [@sjcobs](https://forums.unrealengine.com/u/sjcobs)\
**Post date:** [October 16, 2018, 4:46am UTC](https://forums.unrealengine.com/t/i-have-a-couple-questions-about-best-c-practices/435710/4 "2018-10-16T04:46:17Z")

</div>

Header. You could also add it to cpp if you want.
