I Dont understand what is wrong with my code, help me please😔 | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 5

I Dont understand what is wrong with my code, help me please😔

Why the compiler says that int age and string name are private, yes they are but why it is a bug? https://code.sololearn.com/cc2c6hrg8757/?ref=app

13th May 2020, 3:06 PM
Luis.G
Luis.G - avatar
1 Antwort
+ 5
That's because you are trying to access them using Student::Saludar() function which is a memeber function of "Student" class not "person" class Even though student is inheriting person class but as you might know , private members can't be inherited you can declare them protected to let them inheritable. 👇 https://code.sololearn.com/cO0Z3EjauOJd/?ref=app
13th May 2020, 3:17 PM
Arsenic
Arsenic - avatar