Process data with C++

My goal is to feed a C++ class some data on which I can calculate different outcomes and feed them back into a blueprint.
Currently I have a class with a data structure that’s being filled with basically random data (let’s call it data set B) by the C++ as the object is made. The BP then reads that data and acts accordingly. I also have data set A from the BP which I wanna feed the whole process to influence the result of data set B.
As a naive first thought I tried to make another constructor that takes a couple of and saves them in the class, but that didn’t work.

Your question is kind of vague. Can you specify what you are trying to achieve?
Your BP could just have a function that takes in the blueprint-exposed data structure (defined in C++), works on that data. You don’t necessarily have to create an object that contains said data, and you don’t have to specify that object or that data set in the constructor either.

It might work with one function, but I rather have multiple functions since I don’t know how big this thing is gonna be. Essentially what I want is to generate math problems based on past performance. Past performance is normally saved in multiple arrays. It’s also easy to get this data as local variable in a BP. I just want to get this data in a C++ class where some math happens to then get other variables out of it.
What we currently have is just a C++ defined data structure running a few dozen lines of code to randomize the output. Randomized things are for example the type of problem, the correct answer and the other answers.

I feel like I’m still not understanding, in generic terms, what you are trying to do.

You have a C++ class that contains/creates randomized data.
You have a BP class that has other data, takes the data from the C++ class, works on it, and produces some result based on the C++ data and the BP data. Correct?

You didn’t really specify what your problem is. You tried making another constructor that takes “a couple of” (dataset B?) and saves it, but “that” didn’t work.
What exactly do you want to achieve? What is not working? If you have a local variable in BP and it doesn’t work, that’s because a local variable of an object is not instantiated at the beginning. It is basically a reference to an object and not the object itself. So when you try to access it, it’s gonna be null.

You have to have your C++ object created somewhere, pass the exact same C++ object to your blueprint, then work on that C++ object’s data.

Ah I see what’s the problem. Yeah I want to process the data in C++, not the BP. My problem is that I don’t know how to transfer the data from the BP to C++. I’m able to to generate data in a data structure in C++ and give it back to the BP, but I also want to feed the structure some other data beforehand.

My problem is that I don’t know how to transfer the data from the BP to C++.

Oh? That’s easy! You just may be overthinking things.

If you define a function in C++, and expose that function for use in Blueprints by using the UFUNCTION macro, then you’re already doing this. Anytime you call up a C++ function from Blueprint, you’re executing C++ code. It’s as simple as that.

So, if you write your data-processing functions in C++ and expose those functions to Blueprint, just call up those functions and pass in the data you want to do calculations on. If you make your C++ functions return some values, you’ll have access to those return values in the Blueprint editor as well. Couldn’t be easier.

I hope that clarifies things!

Yeah thanks for the help, I figured things out. Basically I tried to do things with some setter functions, but I couldn’t feed them variables because of some small ■■■■ up by me. Now it’s clear and I’m starting to figure things out.