# Can we get data from a class into another class?

**URL:** <https://forums.unrealengine.com/t/can-we-get-data-from-a-class-into-another-class/1166094>\
**Category:** Programming & Scripting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [May 15, 2023, 5:55am UTC](https://forums.unrealengine.com/t/can-we-get-data-from-a-class-into-another-class/1166094 "2023-05-15T05:55:03Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [May 15, 2023, 8:59am UTC](https://forums.unrealengine.com/t/can-we-get-data-from-a-class-into-another-class/1166094/2 "2023-05-15T08:59:22Z")

</div>

The problem with your attempt is that the `Test2` object doesn’t access the good `Test` object.

```auto
@editable TestClass : Test = Test{} # Here you're creating a new Test object using its constructor, so the functions are usable but
# they won't return any data you've set in your code above

```

Ok so basically I think of 3 ways to do this :

- You give a reference to your TestClass (device) when initializing your Test2 class, like this :

```auto
Test2 := class():
    MyDevice:Test

Test := class<unique>(creative_device):
    var TestClass2 : ?Test2 = false

    OnBegin<override>()<suspends> : void =
        set TestClass2 = option{Test2{MyDevice := Self}}

```

Now your Test2 class has a link to your Test device and your functions are working, you just need to unwrap your TestClass2 everytime (surely there’s a bit cleaner way to do it)

- You try to implement singletons as described in [I came up with a way to make singletons in Verse](https://forums.unrealengine.com/t/i-came-up-with-a-way-to-make-singletons-in-verse/1139453)  
This solution is cleaner if you’re gonna have lots of classes each connected to eachother.

- You make your Test2 a device too, and with @editable attribute you assign both the Test and Test2 to eachother inside UEFN.

---

_[View the full topic](https://forums.unrealengine.com/t/can-we-get-data-from-a-class-into-another-class/1166094)._
