What is circular inheritance? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

What is circular inheritance?

22nd Feb 2016, 12:37 AM
Julian Wittische
Julian Wittische - avatar
2 Answers
+ 6
its when you have a class that inherits from another class that inherits from the first class mentioned... let me explain better haha lets say this: class A(B): #body of class A class B(A): #body of class B this code won't work because B is not defined when I create class A... but it proves the concept of circular inheritance. class A inherits from B and B from A... so you're just creating a loop of inheritance, and python would not be able to evaluate this since there's no way to look at any class individually. It's called circular because you're closing a circle of inheritance by doing this. Hope this helps
2nd Mar 2016, 2:35 AM
Alejandro Aristizabal
Alejandro Aristizabal - avatar
+ 5
it's when A is the superclass and B inherits from A, and C inherits from B, and A inherits from C, forming a circle
10th Mar 2016, 1:49 PM
Oussama Abbas
Oussama Abbas - avatar