{"id":13478,"date":"2025-03-26T09:05:00","date_gmt":"2025-03-26T04:05:00","guid":{"rendered":"https:\/\/afzalbadshah.com\/?p=13478"},"modified":"2025-11-11T09:28:06","modified_gmt":"2025-11-11T04:28:06","slug":"abstract-classes-and-interfaces-designing-extensible-frameworks","status":"publish","type":"post","link":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/","title":{"rendered":"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In our previous lecture, we explored <strong>virtual and pure virtual functions<\/strong>.<br>We saw how a <em>virtual function<\/em> allows different derived classes to perform the same action in their own way \u2014 like different employees performing their duties differently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We also discovered that a <em>pure virtual function<\/em> acts as a promise \u2014 a function that <strong>must<\/strong> be implemented by every derived class.<br>This is where <strong>abstract classes<\/strong> emerge.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An abstract class can be imagined as a <strong>template or blueprint<\/strong> \u2014 it tells us <em>what must exist<\/em>, but not <em>how it works<\/em>.<br>It serves as a foundation for building <strong>extensible frameworks<\/strong>, where future developers can add new components without changing the existing code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why Abstraction Is Needed<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In daily life, abstraction is everywhere.<br>Think of the <strong>employee structure<\/strong> in a large organization. Every employee \u2014 teacher, developer, or manager \u2014 follows the same base rules defined by the organization.<br>The organization acts as a <em>standard interface<\/em>, but what each device does with that electricity differs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is the heart of abstraction:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u201cDefine what should be done, but let others decide how it should be done.\u201d<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">When designing software frameworks \u2014 whether for a school management system or a smart city simulator \u2014 abstraction ensures that the system remains open for growth.<br>New modules can join the system as long as they follow the <strong>same contract<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Understanding Abstract Classes and Interfaces<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Abstract Class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An <strong>abstract class<\/strong> is a class that cannot be instantiated directly.<br>It may have both normal and pure virtual functions.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u201cAn abstract class defines a contract for derived classes \u2014 it says <em>what<\/em> they must do but may partially define <em>how<\/em>.\u201d<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">Interface<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An <strong>interface<\/strong> is a special type of abstract class that has only pure virtual functions \u2014 no data, no implementation.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u201cAn interface is a promise \u2014 it defines behavior but leaves the complete implementation to others.\u201d<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">So in C++:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Every class with at least one pure virtual function is <em>abstract<\/em>.<\/li>\n\n\n\n<li>A class with <strong>only pure virtual functions<\/strong> is considered an <em>interface<\/em>.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Previously, we created an example where an <code>Employee<\/code> class had a virtual function <code>performDuty()<\/code> that was implemented differently by each employee type (like <code>Teacher<\/code> and <code>Developer<\/code>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we will extend that same idea to understand <strong>abstract classes<\/strong> and <strong>interfaces<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Abstract Class Example<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s begin by making <code>Employee<\/code> an abstract class.<br>We\u2019ll add a pure virtual function to define a common responsibility that each employee must perform.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\n\/\/ Abstract Base Class\nclass Employee {\npublic:\n    virtual void performDuty() = 0;   \/\/ Pure virtual function\n    virtual void report() {           \/\/ Normal function\n        cout &lt;&lt; \"Employee reporting to the office.\" &lt;&lt; endl;\n    }\n};\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The presence of <code>= 0<\/code> makes this function <em>pure virtual<\/em>, and thus, <code>Employee<\/code> becomes an abstract class.<br>It cannot be instantiated directly.<br>Any class that inherits from it must define its own version of <code>performDuty()<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s create two types of employees:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Teacher : public Employee {\npublic:\n    void performDuty() override {\n        cout &lt;&lt; \"Teacher is delivering a lecture to students.\" &lt;&lt; endl;\n    }\n};\n\nclass Developer : public Employee {\npublic:\n    void performDuty() override {\n        cout &lt;&lt; \"Developer is writing code for the new application.\" &lt;&lt; endl;\n    }\n};\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we can use <strong>polymorphism<\/strong> to handle all employees through a single interface:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int main() {\n    Employee* e1 = new Teacher();\n    Employee* e2 = new Developer();\n\n    e1-&gt;performDuty();\n    e2-&gt;performDuty();\n\n    e1-&gt;report();  \/\/ Normal function from abstract base class\n\n    delete e1;\n    delete e2;\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd0d Output:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Teacher is delivering a lecture to students.\nDeveloper is writing code for the new application.\nEmployee reporting to the office.\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this setup:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <strong>abstract class<\/strong> <code>Employee<\/code> defines what all employees must be able to do.<\/li>\n\n\n\n<li>Each subclass (<code>Teacher<\/code>, <code>Developer<\/code>) defines how that duty is done.<\/li>\n\n\n\n<li>This structure allows us to add more employee types (like <code>Designer<\/code>, <code>Manager<\/code>) without ever changing the original framework.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This is <strong>extensibility<\/strong> \u2014 a fundamental goal in software architecture.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Interface: When We Need Only the Contract<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Sometimes we don\u2019t even need partial implementation \u2014 we just need to define behavior that different classes can \u201cagree\u201d to follow.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For instance, in a school system, some employees receive payments.<br>Others may not (like unpaid interns).<br>Let\u2019s define an <strong>interface<\/strong> for that:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Payable {\npublic:\n    virtual void processPayment() = 0;\n    virtual ~Payable() {} \/\/ Always define a virtual destructor in interfaces\n};\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, <code>Teacher<\/code> and <code>Developer<\/code> can \u201cimplement\u201d this interface:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Teacher : public Employee, public Payable {\npublic:\n    void performDuty() override {\n        cout &lt;&lt; \"Teacher is delivering a lecture.\" &lt;&lt; endl;\n    }\n    void processPayment() override {\n        cout &lt;&lt; \"Teacher receives monthly salary.\" &lt;&lt; endl;\n    }\n};\n\nclass Developer : public Employee, public Payable {\npublic:\n    void performDuty() override {\n        cout &lt;&lt; \"Developer is writing project code.\" &lt;&lt; endl;\n    }\n    void processPayment() override {\n        cout &lt;&lt; \"Developer receives project-based payment.\" &lt;&lt; endl;\n    }\n};\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And in <code>main()<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int main() {\n    Payable* p1 = new Teacher();\n    Payable* p2 = new Developer();\n\n    p1-&gt;processPayment();\n    p2-&gt;processPayment();\n\n    delete p1;\n    delete p2;\n    return 0;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd0d Output:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Teacher receives monthly salary.\nDeveloper receives project-based payment.\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This structure allows one class to <strong>play multiple roles<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Employee<\/code> \u2192 defines what it means to be an employee (performing duties).<\/li>\n\n\n\n<li><code>Payable<\/code> \u2192 defines what it means to be paid (processing payments).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">C++ supports <strong>multiple inheritance<\/strong> safely in such interface scenarios because interfaces typically have no data \u2014 only pure virtual functions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This concept is used widely in real frameworks:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In <strong>game engines<\/strong>, an object can be both <code>Drawable<\/code> and <code>Updatable<\/code>.<\/li>\n\n\n\n<li>In <strong>network systems<\/strong>, a device can be both <code>Connectable<\/code> and <code>Rechargeable<\/code>.<\/li>\n\n\n\n<li>In <strong>simulation models<\/strong>, an entity can be both <code>Communicable<\/code> and <code>Mobile<\/code>.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Type<\/strong><\/th><th><strong>Can Be Instantiated<\/strong><\/th><th><strong>Contains Pure Virtual Functions<\/strong><\/th><th><strong>May Have Implementation<\/strong><\/th><th><strong>Typical Purpose<\/strong><\/th><\/tr><\/thead><tbody><tr><td>Concrete Class<\/td><td>\u2705 Yes<\/td><td>\u274c No<\/td><td>\u2705 Yes<\/td><td>Fully defined behavior and data<\/td><\/tr><tr><td>Abstract Class<\/td><td>\u274c No<\/td><td>\u2705 At least one<\/td><td>\u2705 May have partial implementation<\/td><td>Base class defining structure for derived classes<\/td><\/tr><tr><td>Interface<\/td><td>\u274c No<\/td><td>\u2705 All<\/td><td>\u274c No<\/td><td>Defines contracts or roles that multiple classes can adopt<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Self-Assessment<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Conceptual:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Can we create an object of an abstract class? Why not?<\/li>\n\n\n\n<li>How can we represent interfaces in C++?<\/li>\n\n\n\n<li>Why do interfaces often have virtual destructors?<\/li>\n\n\n\n<li>What\u2019s the advantage of having multiple interfaces?<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Coding Task:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add a new class <code>ResearchAssistant<\/code> that:\n<ul class=\"wp-block-list\">\n<li>Inherits from both <code>Employee<\/code> and <code>Payable<\/code><\/li>\n\n\n\n<li>Adds a function <code>conductResearch()<\/code><\/li>\n\n\n\n<li>Implements all required functions and displays messages accordingly.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In our previous lecture, we explored virtual and pure virtual functions.We saw how a virtual function allows different derived classes to perform the same action in their own way \u2014 like different employees performing their duties differently. We also discovered that a pure virtual function acts as a promise \u2014 a function that must be implemented by every derived class.This is where abstract classes emerge. An abstract class can be imagined as a template or blueprint \u2014 it tells us&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":13711,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":false,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[637],"tags":[640,726],"class_list":["post-13478","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oop-with-c","tag-abstract-classes","tag-interfaces"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"In our previous lecture, we explored virtual and pure virtual functions.We saw how a virtual function allows different derived classes to perform the same action in their own way \u2014 like different employees performing their duties differently. We also discovered that a pure virtual function acts as a promise \u2014 a function that must be\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Afzal Badshah, PhD\"\/>\n\t<meta name=\"google-site-verification\" content=\"B8FNGv4w1toMpU3HUnD_SN9H9YMtp1ObsLuEDuirArI\" \/>\n\t<meta name=\"p:domain_verify\" content=\"87b5ca26c36438b20581a102dc290a47\" \/>\n\t<meta name=\"yandex-verification\" content=\"0eb3e2a9157fd34d\" \/>\n\t<meta name=\"keywords\" content=\"abstract classes,interfaces,oop with c++\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_GB\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Afzal Badshah, PhD - Unlocking Mastery in Parenting, Teaching, Learning, Academic, and Life Skills: Your Guide to Excellence\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks - Afzal Badshah, PhD\" \/>\n\t\t<meta property=\"og:description\" content=\"In our previous lecture, we explored virtual and pure virtual functions.We saw how a virtual function allows different derived classes to perform the same action in their own way \u2014 like different employees performing their duties differently. We also discovered that a pure virtual function acts as a promise \u2014 a function that must be\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2025\/11\/OOP-4.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2025\/11\/OOP-4.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2025-03-26T04:05:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2025-11-11T04:28:06+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/web.facebook.com\/abmanduri\/\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@DrAFZALBADSHAH\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks - Afzal Badshah, PhD\" \/>\n\t\t<meta name=\"twitter:description\" content=\"In our previous lecture, we explored virtual and pure virtual functions.We saw how a virtual function allows different derived classes to perform the same action in their own way \u2014 like different employees performing their duties differently. We also discovered that a pure virtual function acts as a promise \u2014 a function that must be\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@DrAFZALBADSHAH\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2025\/11\/OOP-4.jpg\" \/>\n\t\t<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t\t<meta name=\"twitter:data1\" content=\"Afzal Badshah, PhD\" \/>\n\t\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#blogposting\",\"name\":\"Abstract Classes and Interfaces \\u2014 Designing Extensible Frameworks - Afzal Badshah, PhD\",\"headline\":\"Abstract Classes and Interfaces \\u2014 Designing Extensible Frameworks\",\"author\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/author\\\/afzalbadshah-com\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/afzalbadshah.com\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/OOP-4.jpg?fit=1920%2C1080&ssl=1\",\"width\":1920,\"height\":1080},\"datePublished\":\"2025-03-26T09:05:00+05:00\",\"dateModified\":\"2025-11-11T09:28:06+05:00\",\"inLanguage\":\"en-GB\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#webpage\"},\"articleSection\":\"OOP with C++, abstract classes, interfaces\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/afzalbadshah.com\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/#listItem\",\"name\":\"Courses\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/#listItem\",\"position\":2,\"name\":\"Courses\",\"item\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/oop-with-c\\\/#listItem\",\"name\":\"OOP with C++\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/oop-with-c\\\/#listItem\",\"position\":3,\"name\":\"OOP with C++\",\"item\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/oop-with-c\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#listItem\",\"name\":\"Abstract Classes and Interfaces \\u2014 Designing Extensible Frameworks\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/#listItem\",\"name\":\"Courses\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#listItem\",\"position\":4,\"name\":\"Abstract Classes and Interfaces \\u2014 Designing Extensible Frameworks\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/oop-with-c\\\/#listItem\",\"name\":\"OOP with C++\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/#person\",\"name\":\"Afzal Badshah, PhD\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#personImage\",\"url\":\"https:\\\/\\\/afzalbadshah.com\\\/wp-content\\\/litespeed\\\/avatar\\\/27d3d5e33aa81b3152e368c66871f22f.jpg?ver=1787150587\",\"width\":96,\"height\":96,\"caption\":\"Afzal Badshah, PhD\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/author\\\/afzalbadshah-com\\\/#author\",\"url\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/author\\\/afzalbadshah-com\\\/\",\"name\":\"Afzal Badshah, PhD\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#authorImage\",\"url\":\"https:\\\/\\\/afzalbadshah.com\\\/wp-content\\\/litespeed\\\/avatar\\\/27d3d5e33aa81b3152e368c66871f22f.jpg?ver=1787150587\",\"width\":96,\"height\":96,\"caption\":\"Afzal Badshah, PhD\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#webpage\",\"url\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/\",\"name\":\"Abstract Classes and Interfaces \\u2014 Designing Extensible Frameworks - Afzal Badshah, PhD\",\"description\":\"In our previous lecture, we explored virtual and pure virtual functions.We saw how a virtual function allows different derived classes to perform the same action in their own way \\u2014 like different employees performing their duties differently. We also discovered that a pure virtual function acts as a promise \\u2014 a function that must be\",\"inLanguage\":\"en-GB\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/author\\\/afzalbadshah-com\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/author\\\/afzalbadshah-com\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/afzalbadshah.com\\\/wp-content\\\/uploads\\\/2025\\\/11\\\/OOP-4.jpg?fit=1920%2C1080&ssl=1\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#mainImage\",\"width\":1920,\"height\":1080},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2025\\\/03\\\/26\\\/abstract-classes-and-interfaces-designing-extensible-frameworks\\\/#mainImage\"},\"datePublished\":\"2025-03-26T09:05:00+05:00\",\"dateModified\":\"2025-11-11T09:28:06+05:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/#website\",\"url\":\"https:\\\/\\\/afzalbadshah.com\\\/\",\"name\":\"Afzal Badshah, PhD\",\"alternateName\":\"Afzal Badshah\",\"description\":\"Unlocking Mastery in Parenting, Teaching, Learning, Academic, and Life Skills: Your Guide to Excellence\",\"inLanguage\":\"en-GB\",\"publisher\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks - Afzal Badshah, PhD","description":"In our previous lecture, we explored virtual and pure virtual functions.We saw how a virtual function allows different derived classes to perform the same action in their own way \u2014 like different employees performing their duties differently. We also discovered that a pure virtual function acts as a promise \u2014 a function that must be","canonical_url":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/","robots":"max-image-preview:large","keywords":"abstract classes,interfaces,oop with c++","webmasterTools":{"google-site-verification":"B8FNGv4w1toMpU3HUnD_SN9H9YMtp1ObsLuEDuirArI","p:domain_verify":"87b5ca26c36438b20581a102dc290a47","yandex-verification":"0eb3e2a9157fd34d","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#blogposting","name":"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks - Afzal Badshah, PhD","headline":"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks","author":{"@id":"https:\/\/afzalbadshah.com\/index.php\/author\/afzalbadshah-com\/#author"},"publisher":{"@id":"https:\/\/afzalbadshah.com\/#person"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/11\/OOP-4.jpg?fit=1920%2C1080&ssl=1","width":1920,"height":1080},"datePublished":"2025-03-26T09:05:00+05:00","dateModified":"2025-11-11T09:28:06+05:00","inLanguage":"en-GB","mainEntityOfPage":{"@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#webpage"},"isPartOf":{"@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#webpage"},"articleSection":"OOP with C++, abstract classes, interfaces"},{"@type":"BreadcrumbList","@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com#listItem","position":1,"name":"Home","item":"https:\/\/afzalbadshah.com","nextItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/#listItem","name":"Courses"}},{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/#listItem","position":2,"name":"Courses","item":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/","nextItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/oop-with-c\/#listItem","name":"OOP with C++"},"previousItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/oop-with-c\/#listItem","position":3,"name":"OOP with C++","item":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/oop-with-c\/","nextItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#listItem","name":"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks"},"previousItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/#listItem","name":"Courses"}},{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#listItem","position":4,"name":"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks","previousItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/oop-with-c\/#listItem","name":"OOP with C++"}}]},{"@type":"Person","@id":"https:\/\/afzalbadshah.com\/#person","name":"Afzal Badshah, PhD","image":{"@type":"ImageObject","@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#personImage","url":"https:\/\/afzalbadshah.com\/wp-content\/litespeed\/avatar\/27d3d5e33aa81b3152e368c66871f22f.jpg?ver=1787150587","width":96,"height":96,"caption":"Afzal Badshah, PhD"}},{"@type":"Person","@id":"https:\/\/afzalbadshah.com\/index.php\/author\/afzalbadshah-com\/#author","url":"https:\/\/afzalbadshah.com\/index.php\/author\/afzalbadshah-com\/","name":"Afzal Badshah, PhD","image":{"@type":"ImageObject","@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#authorImage","url":"https:\/\/afzalbadshah.com\/wp-content\/litespeed\/avatar\/27d3d5e33aa81b3152e368c66871f22f.jpg?ver=1787150587","width":96,"height":96,"caption":"Afzal Badshah, PhD"}},{"@type":"WebPage","@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#webpage","url":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/","name":"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks - Afzal Badshah, PhD","description":"In our previous lecture, we explored virtual and pure virtual functions.We saw how a virtual function allows different derived classes to perform the same action in their own way \u2014 like different employees performing their duties differently. We also discovered that a pure virtual function acts as a promise \u2014 a function that must be","inLanguage":"en-GB","isPartOf":{"@id":"https:\/\/afzalbadshah.com\/#website"},"breadcrumb":{"@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#breadcrumblist"},"author":{"@id":"https:\/\/afzalbadshah.com\/index.php\/author\/afzalbadshah-com\/#author"},"creator":{"@id":"https:\/\/afzalbadshah.com\/index.php\/author\/afzalbadshah-com\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/11\/OOP-4.jpg?fit=1920%2C1080&ssl=1","@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#mainImage","width":1920,"height":1080},"primaryImageOfPage":{"@id":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/#mainImage"},"datePublished":"2025-03-26T09:05:00+05:00","dateModified":"2025-11-11T09:28:06+05:00"},{"@type":"WebSite","@id":"https:\/\/afzalbadshah.com\/#website","url":"https:\/\/afzalbadshah.com\/","name":"Afzal Badshah, PhD","alternateName":"Afzal Badshah","description":"Unlocking Mastery in Parenting, Teaching, Learning, Academic, and Life Skills: Your Guide to Excellence","inLanguage":"en-GB","publisher":{"@id":"https:\/\/afzalbadshah.com\/#person"}}]},"og:locale":"en_GB","og:site_name":"Afzal Badshah, PhD - Unlocking Mastery in Parenting, Teaching, Learning, Academic, and Life Skills: Your Guide to Excellence","og:type":"article","og:title":"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks - Afzal Badshah, PhD","og:description":"In our previous lecture, we explored virtual and pure virtual functions.We saw how a virtual function allows different derived classes to perform the same action in their own way \u2014 like different employees performing their duties differently. We also discovered that a pure virtual function acts as a promise \u2014 a function that must be","og:url":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/","og:image":"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2025\/11\/OOP-4.jpg","og:image:secure_url":"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2025\/11\/OOP-4.jpg","og:image:width":1920,"og:image:height":1080,"article:published_time":"2025-03-26T04:05:00+00:00","article:modified_time":"2025-11-11T04:28:06+00:00","article:publisher":"https:\/\/web.facebook.com\/abmanduri\/","twitter:card":"summary_large_image","twitter:site":"@DrAFZALBADSHAH","twitter:title":"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks - Afzal Badshah, PhD","twitter:description":"In our previous lecture, we explored virtual and pure virtual functions.We saw how a virtual function allows different derived classes to perform the same action in their own way \u2014 like different employees performing their duties differently. We also discovered that a pure virtual function acts as a promise \u2014 a function that must be","twitter:creator":"@DrAFZALBADSHAH","twitter:image":"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2025\/11\/OOP-4.jpg","twitter:label1":"Written by","twitter:data1":"Afzal Badshah, PhD","twitter:label2":"Est. reading time","twitter:data2":"5 minutes"},"aioseo_meta_data":{"post_id":"13478","title":null,"description":null,"keywords":null,"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":true,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":{"faqs":[],"keyPoints":[],"titles":[],"descriptions":[],"socialPosts":{"email":[],"linkedin":[],"twitter":[],"facebook":[],"instagram":[]}},"created":"2025-11-10 07:07:32","updated":"2025-11-11 04:34:00","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/afzalbadshah.com\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/\" title=\"Courses\">Courses<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/oop-with-c\/\" title=\"OOP with C++\">OOP with C++<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tAbstract Classes and Interfaces \u2014 Designing Extensible Frameworks\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/afzalbadshah.com"},{"label":"Courses","link":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/"},{"label":"OOP with C++","link":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/oop-with-c\/"},{"label":"Abstract Classes and Interfaces \u2014 Designing Extensible Frameworks","link":"https:\/\/afzalbadshah.com\/index.php\/2025\/03\/26\/abstract-classes-and-interfaces-designing-extensible-frameworks\/"}],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2025\/11\/OOP-4.jpg?fit=1920%2C1080&ssl=1","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pf3emP-3vo","jetpack-related-posts":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts\/13478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/comments?post=13478"}],"version-history":[{"count":2,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts\/13478\/revisions"}],"predecessor-version":[{"id":13715,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts\/13478\/revisions\/13715"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/media\/13711"}],"wp:attachment":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/media?parent=13478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/categories?post=13478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/tags?post=13478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}