Skip to content

M) Inheritance DZIEDZICZENIE

kalinosia edited this page Mar 13, 2021 · 3 revisions

It’s a process of creating new classes based on existing ones. Newly created classes inherit data and behaviour from parent class and can provide additional data and behaviour.

{{{ Base } Child } Granchild }

Dziedziczą nie jak w prawdziwym życiu (część od matki część od ojca) tylko wszystko od rodzica. Dziecko zawiera wszystko rodzica+swoje więc wnuk zawiera to wszystko.

class NewClass : public OldClass {
//class New class structure
}

public are public, protected are protected, private are private

class B : protected A {
//class New class structure if so
}

now public metods and attributes are protected

class Dog : private Animal {
//class New class structure if so
}

now everything is private

Clone this wiki locally