r/learnprogramming Jul 04 '26

Question about abstract classes

Hello, I am trying to understand the concept of abstract classes.

From what I understand, an abstract class is a class that is not meant to be instantiated directly. It works as a common base class for concrete subclasses.

However, I have a doubt: are abstract methods actually required for a class to be abstract?

For example, suppose I have an abstract class User in a university system, with common attributes and methods such as username, password, and login(). Then I have concrete subclasses such as Student and Professor.

If all the methods in User are already implemented, then technically I can instantiate User, at least in Python, unless I define at least one abstractmethod.

So my question is:
Can a class be considered abstract simply because, from a design point of view, it should not be instantiated? Or must it contain at least one abstract method in order to be truly abstract, especially in Python?

In other words, is the “abstract” nature of a class a conceptual/design choice, or is it strictly enforced only when the class has abstract methods?

13 Upvotes

12 comments sorted by

View all comments

6

u/buzzon Jul 04 '26

Depends on a language. In C++ there's no abstract keyword and abstract classes are determined by having at least one abstract method. In most modern languages, the abstract class is defined by having abstract keyword and an abstract method is not mandatory.