Question about Inheritance

Hello Everyone,
My question is, when inheriting from a class, whether it be my own or not, does the child class get the variables and functions w/o definitions? or does the child class get the “full package”, definitions and declarations?

The short answer is derived classes get access to both public and protected members/methods. Friends of a class may have access to private members/methods.

The child class will get the functions and variables with definitions. So if you add functions to parent class that are public or protected and then call that function from the child class it will do exactly the same thing as it would if you run it in the parent class. It is when you override a function that you created in the parent class from the child class it becomes a function without a definition until you give it a new definition in the child class.

That interesting because I’ve been following a tutorial and we created a Weapon Class and then derived from that Weapon class and everything I had done in the Parent class wasn’t working with the child. The only way I was able to get everything to work was to re-type most of the code from the parent class into the child class which didn’t make much sense to me. Any ideas why I’m getting this kind of behavior?

When you say “wasn’t working”, do you mean, compilling error or intellisense not working?

For example, In the parent weapon class I had created and assigned a sound effect and two particle effects. But in the child class, none of the effect were working prior to me writing the code in the child class. Now, I did make sure that the effects were assigned in the child class’s blueprint, but I wasn’t getting the results that I expected.

Are you sure you are not overriding the functions? When you create the child class you shouldn’t need to add anything to it. You may need to reassign the default values in the editor but thats it. Have you declared any of the parents functions in the child class by putting override at the end of them in the header file of the child class and have you made the functions in the parent class virtual. It would be a lot easier to answer this if you could post a screenshot of your parent and child class.