TakeDamage() protection questions

I was following Lecture 187 and as per the challenge I created a TakeDamage function. It worked without any issues so I was pretty happy. The logs were called, Damage made sense, all was right in the world.

Then I continued to watch the video and Ben said it had to be a public method. So, i took a quick look and… I made mine private by mistake (Or, more to the point, Visual Studio did because I simply created the the function and told VS to update my .h file). But the weird thing is… it worked.

I dived into the engine code and in Engine\Source\Runtime\Engine\Classes\GameFramework\Actor.h, the method is marked as public. I did specify override in the header file.

Are my assumptions correct that:

A) If the super class defines a function as public and you override it (as private) that the function stays public?
B) If you specify override it only checks that the signature is correct but doesn’t look at the protection level?

They would make sense but is definitely something to keep in mind.

Privacy & Terms