# TArray Add()

**URL:** <https://forums.unrealengine.com/t/tarray-add/130028>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [August 17, 2019, 6:08pm UTC](https://forums.unrealengine.com/t/tarray-add/130028 "2019-08-17T18:08:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![whiteg\_ld](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@whiteg\_ld](https://forums.unrealengine.com/u/whiteg_ld)\
**Post date:** [August 17, 2019, 6:08pm UTC](https://forums.unrealengine.com/t/tarray-add/130028/1 "2019-08-17T18:08:29Z")

</div>

Hello,  
I created a new object of type UStaticMeshComponent and immediately add it to the TArray of StaticMeshComponents.  
However, the compiler writes that:  
Error C2664 “int32 TArray \<UStaticMeshComponent, FDefaultAllocator\> :: Add (const UStaticMeshComponent &)”: cannot convert argument 1 from “UStaticMeshComponent &&”

 ![-1.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/8/282b83c3f221a096b494f3507d07405975720378.png)

---

<div class="post-metadata">

**Author:** ![ExtraLifeMatt](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/extralifematt/32/918695_2.png) [@ExtraLifeMatt](https://forums.unrealengine.com/u/ExtraLifeMatt)\
**Post date:** [August 18, 2019, 2:13am UTC](https://forums.unrealengine.com/t/tarray-add/130028/2 "2019-08-18T02:13:17Z")

</div>

Your TArray is an array of UStaticMeshComponent OBJECTS, not pointers (which is what you are trying to add, correctly).

```auto

TArray<UStaticMeshComponent*> SMArray; // Note the pointer type.

```

---

<div class="post-metadata">

**Author:** ![whiteg\_ld](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@whiteg\_ld](https://forums.unrealengine.com/u/whiteg_ld)\
**Post date:** [August 18, 2019, 7:00am UTC](https://forums.unrealengine.com/t/tarray-add/130028/3 "2019-08-18T07:00:28Z")

</div>

Thank you, this is what I need.

---

<div class="post-metadata">

**Author:** ![Subject73](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Subject73](https://forums.unrealengine.com/u/Subject73)\
**Post date:** [December 23, 2020, 6:12am UTC](https://forums.unrealengine.com/t/tarray-add/130028/4 "2020-12-23T06:12:26Z")

</div>

@ExtraLifeMatt End of 2020 and this information helped again. Props man!
