You need a refference of your Example Object before you can Call anything. Think about it you can spawn 100 different Example Objects. Which one of them does execute the DoSomething? Think about it like you have AEnemy calss and it has a Function called TakeDamge() you surly dont want every AEnemy in your Level to Take Damge right? Just a single one.
But you can also make a static Function this one you can call trough your Namespace like AExample::DoSomething() but in this case it does not get called from the individual Objects. This function does basicly dont know who is the Caller think of it more like a Global think. So if you would have a AEnemy::TakeDamage() it would not know about the AEnemy that does the Call and would not know what specific AEnemy Object should take damage.
But if the static Function does not do anything per Object you can use static.
So now you ask yourself how would you get a refference to a AExample Object? There are many ways but usually you are in charge to Set a refference somewhere up where your ACharacter can reach it. Or get it from Something else like a Overlap Event (you need to Cast to AExample to check if it is indeed a AExample Object you Overlap) same goes for Linetraces. Or wherever you Create the AExample object gets also a refference pointer he can send to other Objects like your PlayerController.
Thats just a rough Explanation I recommand you to pick up a C++ book to learn the foundamentals or take also a look at this Video its for Blueprints but the Communication part falls under the same logic. Get a refference to you desired Object than you can Call functions on it.
Hope this helps you to understand the Problem you are facing right now.