Is it possible to "Get All Actors of Class" from code

I’m pretty new to Unreal Engine and i’m trying to find a way to call this method from a c++ class, and not from blueprint (i’m not going to use them for this project), as explained here:
Is it possible?

I have found this:
i guess it’s the only way to do it. looks nice.

Hi ,

Look at this page

Hope it helps!