Q about Inheritance | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Q about Inheritance

Is it possible to inherent from a base class that's in another script, and if so, how do I declare any inherented member in the derived class.

24th May 2017, 9:46 PM
Denzel Dorisme
Denzel Dorisme - avatar
2 Answers
+ 2
@luka I assume he's using Unity. @Dudamax To inherit you use the syntax : Ex/ class thisclassName : inherittedClass So, : is the indication of the things this class will extend. To access the base class directly use the 'base' keyword. Although if you just want to access variable or methods in the base/derived class, you can just use the protected access modifier. To access the variable directly in the sub-classes.
24th May 2017, 11:23 PM
Rrestoring faith
Rrestoring faith - avatar
0
2 individual c# scripts
24th May 2017, 10:42 PM
Denzel Dorisme
Denzel Dorisme - avatar