Click here to Skip to main content
15,845,436 members
Articles / Programming Languages / C++20

Enforcing a Static Interface in C++

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
2 Feb 2023MIT10 min read 12K   10  
Ways to enforce an interface contract on static methods, similar to what you would expect from static virtual methods if they'd exist in C++
In C++, you can have abstract base classes that are similar to interfaces in dotNET. Only it is not possible to declare static methods that way. This makes it impossible to enforce a class having static methods with a specific parameters list. Using standard C++ behavior, there are some ways we can work around that.


Daily Counts


This article, along with any associated source code and files, is licensed under The MIT License

Written By
Software Developer
Belgium Belgium
I am a former professional software developer (now a system admin) with an interest in everything that is about making hardware work. In the course of my work, I have programmed device drivers and services on Windows and linux.

I have written firmware for embedded devices in C and assembly language, and have designed and implemented real-time applications for testing of satellite payload equipment.

Generally, finding out how to interface hardware with software is my hobby and job.

Comments and Discussions