Typically, Objective-C class are abstract by convention only—if the author documents a class as abstract, just don't use it without subclassing it. There is no compile-time enforcement that prevents instantiation of an abstract class, however. In fact, there is nothing to stop a user from providing implementations of abstract methods via a category (i.e. at runtime). You can force a user to at least override certain methods by raising an exception in those methods implementation in your abstract class:

[NSException raise:NSInternalInconsistencyException 
            format:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)];

If your method returns a value, it's a bit easier to use

@throw [NSException exceptionWithName:NSInternalInconsistencyException
                               reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]
                             userInfo:nil];

as then you don't need to add a return statement from the method.

If the abstract class is really an interface (i.e. has no concrete method implementations), using an Objective-C protocol is the more appropriate option.

Answer from Barry Wark on Stack Overflow
🌐
W3Schools
w3schools.com › cs › cs_abstract.php
C# Abstraction
Abstract class: is a restricted class that cannot be used to create objects (to access it, it must be inherited from another class).
🌐
Cppreference
en.cppreference.com › w › cpp › language › abstract_class.html
Abstract class - cppreference.com
Defines an abstract type which cannot be instantiated, but can be used as a base class.
🌐
GeeksforGeeks
geeksforgeeks.org › c# › c-sharp-abstract-classes
Abstract Class in C# - GeeksforGeeks
September 16, 2025 - We can only create objects of derived classes. Abstract methods are declared in the abstract classes but do not have implementation, derived classes are required to implement them.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › csharp › language-reference › keywords › abstract
abstract keyword - C# reference | Microsoft Learn
Abstract classes can contain both abstract members (which have no implementation and must be overridden in derived classes) and fully implemented members (such as regular methods, properties, and constructors).
🌐
IBM
ibm.com › docs › en › zos › 2.4.0
Abstract classes (C++ only)
We cannot provide a description for this page right now
Top answer
1 of 10
27

The purpose of an abstract class is to define a common protocol for a set of concrete subclasses. This is useful when defining objects that share code, abstract ideas, etc.

Abstract classes have no instances. An abstract class must have at least one deferred method (or function). To accomplish this in C++, a pure virtual member function is declared but not defined in the abstract class:

class MyClass {
    virtual void pureVirtualFunction() = 0;
}

Attempts to instantiate an abstract class will always result in a compiler error.

"What does defining an abstract base class provide that isn't provided by creating each necessary function in each actual class?"

The main idea here is code reuse and proper partitioning across classes. It makes more sense to define a function once in a parent class rather than defining over and over again in multiple subclasses:

class A {
   void func1();
   virtual void func2() = 0;
}

class B : public A {
   // inherits A's func1()
   virtual void func2();   // Function defined in implementation file
}

class C : public A {
   // inherits A's func1()
   virtual void func2();   // Function defined in implementation file
}
2 of 10
22

Having an abstract class like "Dog" with a virtual method like "bark" allows all classes that inherit from Dog to have their bark code called in the same way, even though the Beagle's bark is implemented way differently than the Collie's.

Without a common abstract parent (or at least a common parent with a bark virtual method) it'd be difficult to do the following:

Have a Vector of type Dog that contains Collies, Beagles, German Shepherds etc and make each of them bark. With a Vector of Dogs that contains Collies, Beagles, German Shepherds all you would have to do to make them all bark is to iterate through in a for loop and call bark on each one. Otherwise you'd have to have a separate Vector of Collies, Vector of Beagles etc.

If the question is "why make Dog abstract when it could be concrete, have a virtual bark defined with a default implementation that can be overriden?", the answer would be that this may be acceptable sometimes -- but, from a design perspective, there really isn't any such thing as a Dog that isn't a Collie or a Beagle or some other breed or mix so although they are all Dogs, there is not one of them in reality that is a Dog but not some other derived class too. Also, since dogs barking is so varied from one breed to another, there is unlikely to be any real acceptable default implementation of bark that would be acceptable for any decent group of Dogs.

I hope this helps you understand the purpose: yes, you're going to have to implement bark in each subclass anyway, but the common abstract ancestor lets you treat any subclass as a member of a base class and invoke behaviors that may be conceptually similar like bark but in fact have very different implementations.

Find elsewhere
🌐
Standard C++
isocpp.org › wiki › faq › abcs
Inheritance — Abstract Base Classes (ABCs), C++ FAQ
At the programming language level, an ABC is a class that has one or more pure virtual member functions. You cannot make an object (instance) of an ABC. A member function declaration that turns a normal class into an abstract class (i.e., an ABC).
🌐
QuickStart
quickstart.com › blog › software-engineering › abstract-class-vs-interface-in-c-OOP-concepts
What Is Abstract Class vs Interface In C | OOP concepts in C
October 11, 2024 - These concepts are core to object-oriented programming (OOP) and are often used to model real-world behaviors and system architectures. ... An abstract class serves as a partial implementation of an object. It can contain both implemented and ...
🌐
Wikibooks
en.wikibooks.org › wiki › C++_Programming › Classes › Abstract_Classes
C++ Programming/Classes/Abstract Classes - Wikibooks, open books for an open world
January 15, 2006 - An abstract class is one in which there is a declaration but no definition for a member function. The way this concept is expressed in C++ is to have the member function declaration assigned to zero. ... A pure Abstract class has only abstract member functions and no data or concrete member ...
🌐
TheServerSide
theserverside.com › definition › abstract-class
What is an Abstract Class? | Definition from TechTarget
Declaring a class as abstract means it can't be directly instantiated, which means an object can't be created from it. This protects code from being used incorrectly. Abstract classes require subclasses to further define attributes necessary ...
🌐
Medium
medium.com › @nwonahr › interfaces-vs-abstract-classes-in-c-whats-the-difference-and-when-to-use-them-9af5ab21b1f9
Interfaces vs Abstract Classes in C#: What’s the Difference and When to Use Them | by Richard Nwonah | Medium
September 22, 2024 - If we add a Rectangle class later, it can implement the same interface but with a different implementation. An abstract class allows us to define both the implementation and the contract for derived classes.
🌐
Tutorialspoint
tutorialspoint.com › cplusplus › cpp_interfaces.htm
Interfaces in C++ (Abstract Classes)
The purpose of an abstract class (often referred to as an ABC) is to provide an appropriate base class from which other classes can inherit. Abstract classes cannot be used to instantiate objects and serves only as an interface.
🌐
Embedded
embedded.com › home › abstract types using c
Abstract types using C - Embedded
October 14, 2003 - Listing 1 contains a C99 header file, ring_buffer.h , which defines ring_buffer as an abstract type with supporting functions.
🌐
Quora
quora.com › What-is-the-purpose-of-an-abstract-class-in-C-if-it-doesnt-actually-do-anything
What is the purpose of an abstract class in C# if it doesn't actually do anything? - Quora
Answer (1 of 5): Who said it doesn’t do anything? That’s the main difference between an abstract class and an interface, that the abstract class can actually contain code. You can’t instantiate an abstract class, because it’s likely missing some methods, but that’s different from “it doesn’t do ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › cpp › abstract-classes-cpp
Abstract classes (C++) | Microsoft Learn
You create an abstract class by declaring at least one pure virtual member function. That's a virtual function declared by using the pure specifier (= 0) syntax.
🌐
Educative
educative.io › answers › what-is-a-cpp-abstract-class
What is a C++ abstract class?
Try this: Create a new derived class, such as Bird, and implement the speak() function to print "The bird says: Chirp!". Add a Bird object to the animals vector in the main() function and observe the output. ... Abstract classes provide a way to define a common interface for derived classes while allowing each class to implement its specific behavior.