CINXE.COM

Abstract Class in C++ - Scaler Topics

<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>Abstract Class in C++ - Scaler Topics</title><link rel="canonical" href="https://www.scaler.com/topics/cpp/abstract-class-in-cpp/"/><meta name="robots" content="max-snippet:-1, max-video-preview:-1, max-image-preview:large"/><meta name="description" content="Abstract class in C++ refer to classes containing at least one pure virtual function, which cannot be instantiated. Such classes are mainly used for Upcasting."/><meta name="author" content="Shubh Agarwal"/><meta name="category" content="C++"/><meta property="og:type" content="article"/><meta property="og:title" content="Abstract Class in C++ - Scaler Topics"/><meta property="og:description" content="Abstract class in C++ refer to classes containing at least one pure virtual function, which cannot be instantiated. Such classes are mainly used for Upcasting."/><meta property="og:url" content="https://www.scaler.com/topics/cpp/abstract-class-in-cpp/"/><meta property="og:site_name" content="Scaler Topics"/><meta property="og:image" content="https://www.scaler.com/topics/images/abstract-class-in-cpp.webp"/><meta property="og:image:secure_url" content="https://www.scaler.com/topics/images/abstract-class-in-cpp.webp"/><meta property="og:image:width" content="1680"/><meta property="og:image:height" content="296"/><meta property="og:image:alt" content="Abstract Class in C++ - Scaler Topics"/><meta property="article:published_time" content="2021-09-27T00:00:00.000Z"/><meta name="twitter:site" content="@ScalerTopics"/><meta name="twitter:card" content="summary_large_image"/><meta name="twitter:title" content="Abstract Class in C++ - Scaler Topics"/><meta name="twitter:description" content="Abstract class in C++ refer to classes containing at least one pure virtual function, which cannot be instantiated. Such classes are mainly used for Upcasting."/><meta name="twitter:image" content="https://www.scaler.com/topics/images/abstract-class-in-cpp.webp"/><meta name="twitter:label1" content="Written by"/><meta name="twitter:data1" content="Shubh Agarwal"/><meta name="twitter:label2" content="Time to read"/><meta name="twitter:data2" content="3 mins"/><meta name="next-head-count" content="28"/><link rel="icon" href="/topics/favicon.ico"/><link rel="preconnect" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics"/><link rel="dns-prefetch" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics"/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/media/0ac14a3c407fb3c4-s.p.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-font="size-adjust"/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/media/fc6fba7ce0876fef-s.p.woff2" as="font" type="font/woff2" crossorigin="anonymous" data-next-font="size-adjust"/><script id="article-schema" type="application/ld+json" data-nscript="beforeInteractive" crossorigin="anonymous">{ "@context": "https://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://www.scaler.com/topics/cpp/abstract-class-in-cpp/" }, "headline": "Abstract Class in C++ - Scaler Topics", "image": { "@type": "ImageObject", "url": ["https://www.scaler.com/topics/images/abstract-class-in-cpp.webp"] }, "datePublished": "2021-09-27T00:00:00.000Z", "dateModified": "2021-09-27T00:00:00.000Z", "author": [{"@type":"Person","name":"Shubh Agrawal","url":"https://www.scaler.com/topics/author/shubh-agrawal","image":"https://lh3.googleusercontent.com/a/ACg8ocKvUSQlg-znPsLLVFhkdJIbRbn-RTp3G3gaOho6dFqFrvU=s96-c","jobTitle":"Full Stack Developer Intern","sameAs":["https://www.linkedin.com/in/theshubhagrwl/"]}], "publisher": { "@type": "Organization", "name": "Scaler Topics", "logo": { "@type": "ImageObject", "url": "https://www.scaler.com/topics/media/Scaler_Topics-1.png" } }, "description": "Abstract class in C++ refer to classes containing at least one pure virtual function, which cannot be instantiated. Such classes are mainly used for Upcasting.", "articleSection": "C++", "url": "https://www.scaler.com/topics/cpp/abstract-class-in-cpp/", "wordCount": 689, "inLanguage": "en-IN" }</script><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/d534126c2b78fa37.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/d534126c2b78fa37.css" crossorigin="anonymous" data-n-g=""/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/4c0f02e37a44e2c9.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/4c0f02e37a44e2c9.css" crossorigin="anonymous" data-n-p=""/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/7c735c05af084bb2.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/7c735c05af084bb2.css" crossorigin="anonymous" data-n-p=""/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/165fa169e424a2ec.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/165fa169e424a2ec.css" crossorigin="anonymous" data-n-p=""/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/f904c36152107389.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/f904c36152107389.css" crossorigin="anonymous" data-n-p=""/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/141113e96b07b13e.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/141113e96b07b13e.css" crossorigin="anonymous" data-n-p=""/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/65c6437e87287556.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/65c6437e87287556.css" crossorigin="anonymous"/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/47797229093bb63c.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/47797229093bb63c.css" crossorigin="anonymous"/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/1814549219ea178a.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/1814549219ea178a.css" crossorigin="anonymous"/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/e39e0ebad6bd5384.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/e39e0ebad6bd5384.css" crossorigin="anonymous"/><link rel="preload" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/a11af346a015967e.css" as="style" crossorigin="anonymous"/><link rel="stylesheet" href="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/css/a11af346a015967e.css" crossorigin="anonymous"/><noscript data-n-css=""></noscript><script defer="" crossorigin="anonymous" nomodule="" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script defer="" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/5177.02dd537be8ea20b7.js" crossorigin="anonymous"></script><script defer="" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/3161.b1dc513e17ad7fbe.js" crossorigin="anonymous"></script><script defer="" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/1177-6d4d7d97dc3dfbce.js" crossorigin="anonymous"></script><script defer="" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/2401-b7547d978662b2c2.js" crossorigin="anonymous"></script><script defer="" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/8809.aec60e2150875e0b.js" crossorigin="anonymous"></script><script defer="" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/1631.e3397086ace007b1.js" crossorigin="anonymous"></script><script defer="" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/6770.b20921fa9e8bdafa.js" crossorigin="anonymous"></script><script defer="" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/9605.5238782c3d425495.js" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/webpack-7abfde03f144cc2c.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/framework-84476791e5b56604.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/main-ace78b5142fc8917.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/pages/_app-0db0bcdf594c542f.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/2edb282b-ee9378f1d75cffd2.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/413057b3-57a19db2a0fcc17a.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/94a7ad86-20e09c8aeb1be6e9.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/2272ea81-0b4c4d72740c5692.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/9097-3cd3583c3d4b1241.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/3710-83dbb7be4ba9d86a.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/8421-8d137677ba16bee6.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/8972-e0f7e135826ea562.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/8296-3927c311f1301064.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/5022-b7ffe8abea3c8e44.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/4707-c1c0eaa5bd9b5cad.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/8503-14d9a91c6224a3a5.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/2363-c86cdf7c058c5bf6.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/9298-573b4bea3539387f.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/7680-3154c7084bd03149.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/6026-fbadd3343bdbfd36.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/4866-4d5ab945b9c2c819.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/3376-3344d7df8b1a0dff.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/9339-f12a01444de242e8.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/2097-cc5b1739485d6525.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/9757-601f8db2457745d4.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/2022-18e2f6555326d314.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/4992-f276950658be1ccb.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/568-983f8c4802c0313d.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/2023-8536a91be2699bc5.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/chunks/pages/%5B...slug%5D-f0c04271a154a2f7.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/6jK709HyxmpV6buc4IRmo/_buildManifest.js" defer="" crossorigin="anonymous"></script><script src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/_next/static/6jK709HyxmpV6buc4IRmo/_ssgManifest.js" defer="" crossorigin="anonymous"></script></head><body><div id="__next"><div class="__className_2fe30b full-height column"><div class="Header_header_container__uchwV header_items_headerContainer__Ea7gR articleLayout"><div class="Header_header__links__KRM32"><div class="Header_links_container__4fhhe row sr-container"><div class="row flex-ac"><div role="button" tabindex="0" class="signin-alert-popup_signInWrapper__Kr4eW"><div class="signin-alert-popup_overLay__Xq3de"></div><a class="Tappable-module_root__N7ll5 Header_link_item__Jeq_c Header_hide_above_tablet__YBTTX" target="_blank"><div class="Header_exp_scaler_link__nl8_2 Header_exp_scaler__idDAV"><span class="m-r-xxs">Experience</span><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/scalerLogoWhite.svg" alt="Scaler" height="8" width="60" loading="lazy"/></div></a></div><a href="https://www.scaler.com/?utm_source=topics" class="Header_link_item__Jeq_c Header_hide_below_desktop__JfhVe" target="_blank"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/scalerLogoWhite.svg" alt="Scaler" height="8" width="60" loading="lazy"/></a><div class="Header_item_separator__qyfwr"></div></div><div class="row flex-ac"><a href="https://www.scaler.com/academy/?utm_source=topics" class="Header_link_item__Jeq_c" target="_blank">Academy</a><div class="Header_item_separator__qyfwr"></div></div><div class="row flex-ac"><a href="https://www.scaler.com/data-science-course/?utm_source=topics" class="Header_link_item__Jeq_c" target="_blank">Data Science</a><div class="Header_item_separator__qyfwr"></div></div><div class="row flex-ac"><a href="https://www.scaler.com/neovarsity/?utm_source=topics" class="Header_link_item__Jeq_c" target="_blank">Neovarsity</a></div></div></div><div class="Header_header__scmTs sr-container header_items_article_nav_header__p39r4"><div class="Header_header__branding__lJ8b8"><a class="header__logo Header_logo__YtLXM" href="/topics/"><img class="Header_header__logo_img__Uiby_ show-in-tablet" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/topic_logo.svg" alt="Scaler Topics Logo" width="32" height="32"/><img loading="lazy" class="Header_header__logo_img__Uiby_ hide-in-tablet" src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/ScalerTopics_Logo.svg" alt="Scaler Topics Logo" height="64" width="120"/></a></div><div class="Header_middle_items__oV5uq header_items_middleItem__6JSjC"><div class="full-width Header_header__content__8w1ZO"><div class="header_items_headItems__qhL4j"><div class="header_items_headLinks__y1htd"><div><div class="dropdown"><a class="tappable dropdown__title header_items_header_title__y_fDv"><div class="header_items_header_middle_item__Pyg_d"><span class="m-r-5">Topics</span><svg fill="currentColor" class="icons_icon_chevron__cl99H icons_icon_chevron__down__hhjJu header_items_dropdown_icon__F__ut hide-in-mobile" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M9.875 20.563l-1.875-1.875 8-8 8 8-1.875 1.875-6.125-6.125z"></path></svg></div></a></div></div><div><div class="dropdown"><a class="Tappable-module_root__N7ll5 dropdown__title header_items_header_title__y_fDv"><div class="header_items_header_middle_item__Pyg_d"><span class="m-r-5">Explore</span><svg fill="currentColor" class="icons_icon_chevron__cl99H icons_icon_chevron__down__hhjJu header_items_dropdown_icon__F__ut hide-in-mobile" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M9.875 20.563l-1.875-1.875 8-8 8 8-1.875 1.875-6.125-6.125z"></path></svg></div></a></div></div><div class="row flex-ac header_items_skillTest__container__IVXbl"><div class="dropdown"><a class="tappable dropdown__title header_items_header_title__y_fDv"><div class="relative header_items_header_middle_item__Pyg_d"><div class="row flex-c absolute header_items_header__newTag__A3Rrw tag_tag_container__aoQqR">New</div><div class="row flex-ac m-r-5">Skill Test</div><svg fill="currentColor" class="icons_icon_chevron__cl99H icons_icon_chevron__down__hhjJu header_items_dropdown_icon__F__ut hide-in-mobile" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M9.875 20.563l-1.875-1.875 8-8 8 8-1.875 1.875-6.125-6.125z"></path></svg></div></a></div></div><div><div class="dropdown"><a class="tappable dropdown__title header_items_header_title__y_fDv"><div class="header_items_header_middle_item__Pyg_d"><span class="m-r-5">Courses</span><svg fill="currentColor" class="icons_icon_chevron__cl99H icons_icon_chevron__down__hhjJu header_items_dropdown_icon__F__ut hide-in-mobile" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M9.875 20.563l-1.875-1.875 8-8 8 8-1.875 1.875-6.125-6.125z"></path></svg></div></a></div></div><a data-id="header-item" class="header_items_header_middle_item__Pyg_d" role="link" tabindex="0" href="/topics/events/">Free Masterclass</a></div><div class="row flex-ac space-between"><div class="search_searchbarContainer__x3u_B search-bar_headSearch__9JRJh header_items_search_bar__vmysN header_items_search_bar_article__twdVp hide-in-tablet"><div class="search_container__d1rV9 p-15"><svg fill="currentColor" class="search_search_icon__Kr9M1" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M30.243 28.489l-6.719-6.89c1.716-2.097 2.756-4.806 2.756-7.757 0-0.002 0-0.004 0-0.005v0c-0.009-6.821-5.537-12.349-12.357-12.356h-0.001c-6.821 0.009-12.347 5.535-12.356 12.355v0.001c0.007 6.821 5.535 12.349 12.355 12.358h0.001c0.002 0 0.003 0 0.005 0 2.952 0 5.66-1.040 7.779-2.774l-0.022 0.017 6.719 6.89c0.118 0.118 0.28 0.19 0.46 0.19s0.342-0.073 0.46-0.19l0.92-0.92c0.118-0.118 0.19-0.28 0.19-0.46s-0.073-0.342-0.19-0.46v0zM13.922 23.592c-5.384-0.007-9.747-4.371-9.753-9.755v-0.001c0.007-5.384 4.37-9.746 9.753-9.753h0.001c5.385 0.006 9.748 4.369 9.755 9.753v0.001c-0.006 5.385-4.37 9.749-9.755 9.755h-0.001z"></path></svg><div class="Tappable-module_root__N7ll5 search_search_btn__AjpZg" data-testid="input-id1"><span class="search_search_text__80cj0">Search for Articles, Topics</span></div></div></div></div></div></div><div role="button" tabindex="0" class="signin-alert-popup_signInWrapper__Kr4eW"><div class="signin-alert-popup_overLay__Xq3de"></div><a class="Tappable-module_root__N7ll5 Header_link_item__Jeq_c" target="_blank"><div class="Header_exp_scaler_link__nl8_2 Header_exp_scaler__idDAV hide-in-mobile show-in-tablet"><span class="m-r-xxs">Experience</span><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/scalerLogoWhite.svg" alt="Scaler" height="8" width="60" loading="lazy"/></div></a></div><input type="button" class="Header_header_signin__H8u_q cursor hide-in-tablet" value="Sign In"/><div role="button" tabindex="0" class="signin-alert-popup_signInWrapper__Kr4eW"><div class="signin-alert-popup_overLay__Xq3de"></div><a class="Tappable-module_root__N7ll5 Header_exp_scaler__idDAV Header_hide_in_small_screen__rcYLc" target="_blank">Experience Scaler</a></div></div><div class="show-in-tablet show-in-tablet"><button type="button" class="header_items_hamburger_btn__xaYX0 cursor"><svg fill="currentColor" class="header_items_hamburger_icon__3lUyt" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M27.324 14.969h-22.652c-0.569 0-1.029 0.461-1.029 1.029s0.461 1.029 1.029 1.029h22.652c0.569 0 1.029-0.461 1.029-1.029s-0.461-1.029-1.029-1.029v0z"></path><path d="M4.672 8.793h22.652c0.569 0 1.029-0.461 1.029-1.029s-0.461-1.029-1.029-1.029h-22.652c-0.569 0-1.029 0.461-1.029 1.029s0.461 1.029 1.029 1.029v0z"></path><path d="M27.324 23.207h-22.652c-0.569 0-1.029 0.461-1.029 1.029s0.461 1.029 1.029 1.029h22.652c0.569 0 1.029-0.461 1.029-1.029s-0.461-1.029-1.029-1.029v0z"></path></svg></button></div></div></div><main class="mainContainer articlePage articleLayout"><div class="view_view_container__AUfnF"><div class="row flex-jc"><div class="view_left_section__zPSLG"><div class="view_main_container__Id57J view_ar_container__LNAHP"><div><div class="row space-between m-b-xxs"><div class="row"><div class="hide-in-tablet breadcrumb_container__HwKni view_breadcrumb_display__dKFsT"><div data-id="breadcrumb" class="breadcrumb_item__jdd_h" href="/topics/"><div data-tip="Home" data-place="bottom"><svg fill="currentColor" class="breadcrumb_link_icon__28vc6 column flex-ac" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 33 32"><path d="M26.089 27.6h-5.647c-0.001 0-0.002 0-0.003 0-1.033 0-1.871-0.834-1.877-1.866v-5.657c0-0.004-0.004-0.008-0.008-0.008v0h-3.768c-0.004 0-0.008 0.004-0.008 0.008v0 5.656c-0.006 1.032-0.844 1.866-1.876 1.867h-5.652c-1.032-0.002-1.869-0.835-1.875-1.866v-10.897s0-0.011 0-0.015c0.010-0.535 0.238-1.016 0.598-1.358l0.001-0.001 0.013-0.012 9.419-8.56c0.332-0.305 0.778-0.493 1.267-0.493s0.934 0.187 1.268 0.494l-0.001-0.001 9.429 8.569c0.361 0.343 0.589 0.823 0.599 1.357l0 0.002s0 0.011 0 0.015v10.899c-0.006 1.032-0.844 1.867-1.877 1.867-0 0-0.001 0-0.001 0h0zM14.787 18.199h3.768c1.035 0.002 1.873 0.84 1.875 1.875v5.66c0 0.004 0.004 0.008 0.008 0.008v0h5.651c0.004 0 0.008-0.004 0.008-0.008v0-10.883c-0.001-0.010-0.005-0.020-0.012-0.027l0 0-9.421-8.557-9.408 8.549c-0.007 0.007-0.011 0.016-0.012 0.027v10.891c0 0.004 0.004 0.008 0.008 0.008v0h5.651c0.004 0 0.008-0.004 0.008-0.008v0-5.656c0.001-1.036 0.841-1.876 1.877-1.876v0z"></path></svg></div><div class="__react_component_tooltip t60c678ec-e9b9-4bfe-81f1-8e049d714bb5 place-top type-dark" id="t60c678ec-e9b9-4bfe-81f1-8e049d714bb5" data-id="tooltip"><style aria-hidden="true"> .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5 { color: #fff; background: #222; border: 1px solid transparent; border-radius: undefinedpx; padding: 8px 21px; } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-top { margin-top: -10px; } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-top::before { content: ""; background-color: inherit; position: absolute; z-index: 2; width: 20px; height: 12px; } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-top::after { content: ""; position: absolute; width: 10px; height: 10px; border-top-right-radius: undefinedpx; border: 1px solid transparent; background-color: #222; z-index: -2; bottom: -6px; left: 50%; margin-left: -6px; transform: rotate(135deg); } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-bottom { margin-top: 10px; } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-bottom::before { content: ""; background-color: inherit; position: absolute; z-index: -1; width: 18px; height: 10px; } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-bottom::after { content: ""; position: absolute; width: 10px; height: 10px; border-top-right-radius: undefinedpx; border: 1px solid transparent; background-color: #222; z-index: -2; top: -6px; left: 50%; margin-left: -6px; transform: rotate(45deg); } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-left { margin-left: -10px; } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-left::before { content: ""; background-color: inherit; position: absolute; z-index: -1; width: 10px; height: 18px; } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-left::after { content: ""; position: absolute; width: 10px; height: 10px; border-top-right-radius: undefinedpx; border: 1px solid transparent; background-color: #222; z-index: -2; right: -6px; top: 50%; margin-top: -6px; transform: rotate(45deg); } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-right { margin-left: 10px; } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-right::before { content: ""; background-color: inherit; position: absolute; z-index: -1; width: 10px; height: 18px; } .t60c678ec-e9b9-4bfe-81f1-8e049d714bb5.place-right::after { content: ""; position: absolute; width: 10px; height: 10px; border-top-right-radius: undefinedpx; border: 1px solid transparent; background-color: #222; z-index: -2; left: -6px; top: 50%; margin-top: -6px; transform: rotate(-135deg); } </style></div></div><svg fill="currentColor" class="icons_icon_chevron__cl99H icons_icon_chevron__right__YxLYH hide-in-tablet" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M9.875 20.563l-1.875-1.875 8-8 8 8-1.875 1.875-6.125-6.125z"></path></svg><div class="breadcrumb_seperator__GMDUz show-in-tablet"></div><a data-testid="breadcrumbs-id" href="/topics/hubs/"><div data-id="breadcrumb" data-tip="" data-place="bottom" class="breadcrumb_item__jdd_h"><div data-tip="Reading Tracks" data-place="bottom"><svg fill="currentColor" stroke="" class="breadcrumb_link_icon__28vc6 column flex-ac" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M14 16.56c-0.309 0-0.56-0.251-0.56-0.56v0-12c0-0.309 0.251-0.56 0.56-0.56s0.56 0.251 0.56 0.56v10.88l3.104-2.328c0.092-0.070 0.209-0.112 0.336-0.112s0.244 0.042 0.337 0.113l-0.001-0.001 3.104 2.328v-10.88c0-0.309 0.251-0.56 0.56-0.56s0.56 0.251 0.56 0.56v12c0 0.309-0.251 0.56-0.56 0.56-0.127 0-0.244-0.042-0.337-0.113l0.001 0.001-3.664-2.748-3.664 2.748c-0.092 0.070-0.209 0.112-0.336 0.112v0z"></path><path d="M6 27.56c-0.309 0-0.56-0.251-0.56-0.56v0-20c0-0 0-0.001 0-0.001 0-0.983 0.397-1.873 1.040-2.519l-0 0c0.638-0.642 1.523-1.040 2.5-1.040 0.003 0 0.006 0 0.010 0h17.011c0.309 0 0.56 0.251 0.56 0.56v0 20c0 0.309-0.251 0.56-0.56 0.56v0h-17.013c0 0-0 0-0 0-1.337 0-2.421 1.080-2.427 2.415v0.025c0 0.309-0.251 0.56-0.56 0.56v0zM8.987 4.56c-0.002 0-0.004 0-0.007 0-0.668 0-1.273 0.272-1.71 0.711l-0 0c-0.439 0.442-0.711 1.051-0.711 1.723 0 0.001 0 0.002 0 0.003v-0 17.402c0.629-0.595 1.48-0.96 2.416-0.96 0.004 0 0.008 0 0.012 0h16.453v-18.88z"></path><path d="M24 28.56h-18c-0.309 0-0.56-0.251-0.56-0.56v0-1c0-0.309 0.251-0.56 0.56-0.56s0.56 0.251 0.56 0.56v0 0.44h17.44c0.309 0 0.56 0.251 0.56 0.56s-0.251 0.56-0.56 0.56v0z"></path></svg></div></div></a><svg fill="currentColor" class="icons_icon_chevron__cl99H icons_icon_chevron__right__YxLYH hide-in-tablet" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M9.875 20.563l-1.875-1.875 8-8 8 8-1.875 1.875-6.125-6.125z"></path></svg><div class="breadcrumb_seperator__GMDUz show-in-tablet"></div><a data-testid="breadcrumbs-id" href="/topics/cpp/"><div data-id="breadcrumb" data-tip="C++ Tutorial" data-place="bottom" class="breadcrumb_item__jdd_h breadcrumb_article_title_second_last__Udroe">C++ Tutorial</div></a><svg fill="currentColor" class="icons_icon_chevron__cl99H icons_icon_chevron__right__YxLYH hide-in-tablet breadcrumb_isLastSeparator__nSYW7" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M9.875 20.563l-1.875-1.875 8-8 8 8-1.875 1.875-6.125-6.125z"></path></svg><div class="breadcrumb_seperator__GMDUz show-in-tablet breadcrumb_isLastSeparator__nSYW7"></div><div data-id="breadcrumb" data-tip="" data-place="bottom" class="breadcrumb_item__jdd_h breadcrumb_isLast__v_LIa breadcrumb_title_display__TIbaq breadcrumb_article_title_last__OySmK">Abstract Class in C++</div></div><div class="show-in-tablet breadcrumb_mobile_container__JPiqx view_breadcrumb_display__dKFsT"><div class="row flex-ac" aria-hidden="true"><svg fill="currentColor" class="icons_icon_chevron__cl99H icons_icon_chevron__left__TwvkN breadcrumb_back_icon__a6Usx" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M9.875 20.563l-1.875-1.875 8-8 8 8-1.875 1.875-6.125-6.125z"></path></svg><div class="breadcrumb_title_display__TIbaq breadcrumb_article_title_last__OySmK">Abstract Class in C++</div></div></div></div><div class="row align-c view_util_wrapper__VJgtk"><div role="button" tabindex="0" class="signin-alert-popup_signInWrapper__Kr4eW"><div class="signin-alert-popup_overLay__Xq3de"></div><a class="Tappable-module_root__N7ll5 row cheatsheet_cheatsheet_btn__OjmuY" target="_blank"><div class="row flex-c"><svg fill="currentColor" class="cheatsheet_cheatsheet_btn__download_icon__yjWYo" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 36 28"><path d="M10.043 13.043c0.391-0.391 1.024-0.391 1.414 0l4.543 4.543 4.543-4.543c0.391-0.391 1.024-0.391 1.414 0s0.39 1.024 0 1.414l-5.25 5.25c-0.391 0.39-1.024 0.39-1.414 0l-5.25-5.25c-0.391-0.391-0.391-1.024 0-1.414z"></path><path d="M16 4c0.552 0 1 0.448 1 1v14c0 0.552-0.448 1-1 1s-1-0.448-1-1v-14c0-0.552 0.448-1 1-1z"></path><path d="M5 18c0.552 0 1 0.448 1 1v7h20v-7c0-0.552 0.448-1 1-1s1 0.448 1 1v7c0 0.53-0.211 1.039-0.586 1.414s-0.884 0.586-1.414 0.586h-20c-0.53 0-1.039-0.211-1.414-0.586s-0.586-0.884-0.586-1.414v-7c0-0.552 0.448-1 1-1z"></path></svg></div><span class=""><span class="cheatsheet_cheatsheet_btn__text__lWQa7">C++</span> <!-- -->Cheatsheet</span></a></div><div class="shareButton_share__Vm9x8 shareButton_buttonHover__AmSQt row flex-c"><svg fill="currentColor" class="" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M8 11.333c2.577 0 4.667 2.089 4.667 4.667s-2.089 4.667-4.667 4.667c-2.577 0-4.667-2.089-4.667-4.667v0c0-2.577 2.089-4.667 4.667-4.667v0zM8 19.333c1.841 0 3.333-1.492 3.333-3.333s-1.492-3.333-3.333-3.333c-1.841 0-3.333 1.492-3.333 3.333v0c0 1.841 1.492 3.333 3.333 3.333v0z"></path><path d="M22 20.333c2.577 0 4.667 2.089 4.667 4.667s-2.089 4.667-4.667 4.667c-2.577 0-4.667-2.089-4.667-4.667v0c0-2.577 2.089-4.667 4.667-4.667v0zM22 28.333c1.841 0 3.333-1.492 3.333-3.333s-1.492-3.333-3.333-3.333c-1.841 0-3.333 1.492-3.333 3.333v0c0 1.841 1.492 3.333 3.333 3.333v0z"></path><path d="M22 2.333c2.577 0 4.667 2.089 4.667 4.667s-2.089 4.667-4.667 4.667c-2.577 0-4.667-2.089-4.667-4.667v0c0-2.577 2.089-4.667 4.667-4.667v0zM22 10.333c1.841 0 3.333-1.492 3.333-3.333s-1.492-3.333-3.333-3.333c-1.841 0-3.333 1.492-3.333 3.333v0c0 1.841 1.492 3.333 3.333 3.333v0z"></path><path d="M11.364 14.505c-0 0-0 0-0 0-0.234 0-0.441-0.121-0.56-0.304l-0.002-0.003c-0.066-0.102-0.106-0.227-0.106-0.361 0-0.234 0.121-0.44 0.303-0.559l0.003-0.002 7.272-4.675c0.102-0.066 0.227-0.106 0.361-0.106 0.234 0 0.44 0.121 0.559 0.303l0.002 0.003c0.066 0.102 0.106 0.227 0.106 0.361 0 0.234-0.121 0.44-0.303 0.559l-0.003 0.002-7.272 4.675c-0.102 0.067-0.226 0.106-0.36 0.107h-0z"></path><path d="M18.635 23.503c-0 0-0 0-0 0-0.134 0-0.258-0.039-0.362-0.107l0.003 0.002-7.271-4.675c-0.186-0.12-0.307-0.327-0.307-0.561 0-0.134 0.039-0.258 0.107-0.363l-0.002 0.003c0.12-0.186 0.327-0.307 0.561-0.307 0.134 0 0.258 0.039 0.363 0.107l-0.003-0.002 7.272 4.675c0.186 0.12 0.307 0.327 0.307 0.561 0 0.368-0.298 0.667-0.667 0.667-0.001 0-0.001 0-0.002 0h0z"></path></svg></div></div></div><h1 class="view_title__pgLhk">Abstract Class in C++</h1><div class="full-width m-t-xxs"><div class="article-author_author_name__C_DzB">By <!-- -->Shubh Agrawal</div><div class="article-author_article_time_detail__SHs2n row flex-ac m-b-xs"><span class="flex-c column">3 mins<!-- --> <!-- -->read</span><span class="row flex-c"><div class="article-author_dot_icon__aXBV3 m-r-s"></div><span class="">Last updated: <!-- -->4 Jan 2024</span></span><span class="row flex-c"><div class="article-author_dot_icon__aXBV3 m-r-s"></div><span class="">764<!-- --> views</span></span></div></div><div><div class="row flex-ac space-between full-width p-l-xxs m-b-xs h2 articleWidget_articleWidget__heading___Kzbi"><div class="row flex-ac"><div class="bold">Learn via video course</div><div class="row flex-c bold p-h-xxs m-l-xxs articleWidget_free__tag__vIwTN"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/free.svg" height="12" width="12" loading="lazy"/><span>FREE</span></div></div><a class="Tappable-module_root__N7ll5 row flex-ac hide-in-tablet h6 articleWidget_articleWidget__allCourses__AYnp4" data-name="courses" data-id="explore_all_courses" href="/topics/courses/"><div>View all courses</div><svg fill="currentColor" class="icons_icon_arrow__2GBht icons_icon_arrow__right__WUCHP" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 32 32"><path d="M5.313 16l10.688-10.688 10.688 10.688-1.938 1.875-7.438-7.438v16.25h-2.625v-16.25l-7.5 7.438z"></path></svg></a></div><div class="m-t-xs full-width"><div class="hide-in-mobile"><div class="row flex-c m-b-s commonStyles_course__5KIBa"><div class="row full-width commonStyles_course__details__VTAiI"><img src="https://www.scaler.com/topics/images/instructor-prateek.webp" alt="C++ Course: Learn the Essentials" class="commonStyles_course__image__nuZPe" width="96" height="96" loading="lazy"/><div class="row flex-ac space-between p-h-xs flex-fill full-width"><div class="column full-width"><div class="bold h5 commonStyles_course__title__YnVda">C++ Course: Learn the Essentials</div><div class="row flex-ac m-t-xxs"><div class="commonStyles_course__instructor__4rwsk row align-c bold h6">by <span class="bold p-l-5">Prateek Narang</span></div><div class="m-h-xxs commonStyles_course__divider__UuloR"></div><div class="row align-c"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/user-circle-check.svg" height="16" width="16" loading="lazy"/><div class="h6 commonStyles_course__users__tth8m">1000</div></div><div class="m-h-xxs commonStyles_course__divider__UuloR"></div><div class="row align-c"><svg fill="currentColor" class="commonStyles_course__star__1Giwp" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 32 32"><path d="M7.569 30.625c-0.335 0-0.667-0.103-0.949-0.309-0.529-0.382-0.775-1.039-0.631-1.675l1.963-8.65-6.659-5.84c-0.489-0.427-0.676-1.104-0.475-1.724 0.201-0.618 0.747-1.056 1.395-1.115l8.811-0.8 3.485-8.153c0.257-0.599 0.843-0.986 1.492-0.986 0.651 0 1.235 0.386 1.492 0.983l3.484 8.155 8.81 0.8c0.649 0.058 1.195 0.497 1.397 1.115 0.201 0.619 0.014 1.296-0.476 1.724l-6.659 5.839 1.964 8.651c0.144 0.636-0.102 1.293-0.63 1.675-0.527 0.381-1.229 0.411-1.783 0.078l-7.598-4.541-7.598 4.543c-0.257 0.153-0.544 0.23-0.832 0.23z"></path></svg><div class="h6 commonStyles_course__rating__z4fFS">5</div></div></div></div><a class="tappable commonStyles_learning_button__JYLbC full-width hide-in-tablet h6 commonStyles_course__button__S_dPP" href="/topics/course/cpp-beginners/">Start Learning </a></div></div><div class="show-in-tablet hide-in-mobile full-width m-b-xxs"><div class="row commonStyles_course__button_container__AXSRL"><a class="tappable commonStyles_learning_button__JYLbC full-width row h6 commonStyles_course__button__S_dPP commonStyles_course__button_start__sqRBe" href="/topics/course/cpp-beginners/">Start Learning </a><a class="Tappable-module_root__N7ll5 row h6 commonStyles_course__button__S_dPP commonStyles_course__button_view__I1sQA" data-name="courses" data-id="explore_all_courses" href="/topics/courses/">View all courses<svg fill="currentColor" class="icons_icon_arrow__2GBht icons_icon_arrow__right__WUCHP m-l-xxs" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 32 32"><path d="M5.313 16l10.688-10.688 10.688 10.688-1.938 1.875-7.438-7.438v16.25h-2.625v-16.25l-7.5 7.438z"></path></svg></a></div></div></div></div><div class="show-in-mobile"><div class="column space-between"><div class="row flex-ac mobile_course__container__V2Cw_"><img src="https://www.scaler.com/topics/images/instructor-prateek.webp" alt="C++ Course: Learn the Essentials" width="84" height="84" class="mobile_mobile_cover_img__tl6Lf" loading="lazy"/><div class="column p-t-xxs mobile_course__details_inArticle__jS5sf"><span class="mobile_course_details_title__r6JOj mobile_course_details_title_inArticle___zldf bold">C++ Course: Learn the Essentials</span><div class="row flex-ac m-t-xxs mobile_data__container_inArticle__LlP8z"><span class="mobile_instructor_inArticle__FO1Rg">by <!-- -->Prateek Narang</span><div class="m-h-xxs mobile_divider__FFVtB"></div><div class="row align-c"><svg fill="currentColor" class="mobile_icon__user__HXGxc" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 32 32"><path d="M15.004 11.5c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zM9.004 15.5c0-3.3 2.7-6 6-6s6 2.7 6 6-2.7 6-6 6-6-2.7-6-6z"></path><path d="M15.004 21.5c-1.5 0-2.9 0.4-4.2 1.2s-2.3 1.9-2.9 3.2c-0.3 0.5-0.9 0.7-1.3 0.4-0.6-0.2-0.8-0.8-0.5-1.3 0.8-1.6 2.1-3 3.7-4s3.4-1.5 5.2-1.5c1.8 0 3.7 0.5 5.2 1.5 1.6 1 2.8 2.3 3.7 4 0.2 0.5 0.1 1.1-0.4 1.3s-1.1 0.1-1.3-0.4c-0.7-1.3-1.7-2.4-2.9-3.2-1.4-0.8-2.8-1.2-4.3-1.2z"></path><path d="M15.004 29.5c-0.8 0-1.7-0.1-2.5-0.3-2.5-0.5-4.8-1.7-6.7-3.6-1.8-1.7-3-4-3.5-6.6-0.6-2.5-0.3-5.1 0.7-7.5s2.6-4.4 4.8-5.8c2.1-1.4 4.6-2.2 7.2-2.2 0.7 0 1.4 0.1 2 0.2 0.5 0.1 0.9 0.6 0.8 1.1s-0.6 0.9-1.1 0.8c-0.6-0.1-1.1-0.1-1.7-0.1-2.2 0-4.3 0.6-6.1 1.9-1.8 1.2-3.2 2.9-4.1 4.9s-1.1 4.2-0.6 6.4c0.4 2.1 1.5 4.1 3 5.6s3.5 2.6 5.6 3c2.1 0.4 4.3 0.2 6.4-0.6 2-0.8 3.7-2.2 4.9-4.1 1.2-1.8 1.9-3.9 1.9-6.1 0-1.3-0.2-2.5-0.6-3.7-0.2-0.5 0.1-1.1 0.6-1.3s1.1 0.1 1.3 0.6c0.5 1.4 0.8 2.9 0.7 4.3 0 2.6-0.8 5.1-2.2 7.2s-3.5 3.8-5.8 4.8c-1.6 0.8-3.3 1.1-5 1.1z"></path><path d="M29.704 2.8c0.4 0.4 0.4 1 0 1.4l-4.7 5c-0.2 0.2-0.5 0.3-0.7 0.3-0.3 0-0.5-0.1-0.7-0.3l-2.3-2.5c-0.4-0.4-0.4-1 0-1.4s1-0.4 1.4 0l1.6 1.7 3.9-4.2c0.4-0.4 1.1-0.4 1.5 0z"></path></svg><span class="mobile_course__info__6TMCv">1000</span></div><div class="m-h-xxs mobile_divider__FFVtB"></div><div class="row flex-ac"><svg fill="currentColor" class="mobile_icon__star__Fn2x0" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 32 32"><path d="M7.569 30.625c-0.335 0-0.667-0.103-0.949-0.309-0.529-0.382-0.775-1.039-0.631-1.675l1.963-8.65-6.659-5.84c-0.489-0.427-0.676-1.104-0.475-1.724 0.201-0.618 0.747-1.056 1.395-1.115l8.811-0.8 3.485-8.153c0.257-0.599 0.843-0.986 1.492-0.986 0.651 0 1.235 0.386 1.492 0.983l3.484 8.155 8.81 0.8c0.649 0.058 1.195 0.497 1.397 1.115 0.201 0.619 0.014 1.296-0.476 1.724l-6.659 5.839 1.964 8.651c0.144 0.636-0.102 1.293-0.63 1.675-0.527 0.381-1.229 0.411-1.783 0.078l-7.598-4.541-7.598 4.543c-0.257 0.153-0.544 0.23-0.832 0.23z"></path></svg><span class="mobile_course__info__6TMCv">5</span></div></div></div></div><a class="tappable commonStyles_learning_button__JYLbC full-width" href="/topics/course/cpp-beginners/">Start Learning </a></div></div></div></div><div class="m-t-s article-outline_outline__0_P6T"><a class="Tappable-module_root__N7ll5 row full-width bold article-outline_outline__heading__YVedg"><svg fill="currentColor" class="icons_icon_chevron__cl99H icons_icon_chevron__right__YxLYH" version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 32 32"><path d="M9.875 20.563l-1.875-1.875 8-8 8 8-1.875 1.875-6.125-6.125z"></path></svg><div>Topics Covered</div></a></div><div class="markdown-body"><section class="main"><p>In C++, an abstract class is defined by having at least one pure virtual function, a function without a concrete definition. These classes are essential in object-oriented programming, structuring code to mirror real-life scenarios through inheritance and abstraction. Abstract classes, which cannot be instantiated, are pivotal for expressing broad concepts and upcasting, allowing derived classes to implement their interfaces. Utilize pointers and references for abstract class types, and remember that any subclass failing to define the pure virtual function becomes abstract itself. The virtual function is declared with the pure specifier (= 0).</p><h2 id="abstract-class-in-c---example" level="2">Abstract Class in C++ Example</h2><p>Let’s say we are making a calculator which returns the perimeter of the shape we put in. Think of what kind of code you would write for such a calculator. You might start with some initial shapes and hardcode the perimeter by making separate functions inside the Shape class.</p><p>The class might look something like this –</p><pre><div class="code-box_snippetContainer__cJ6zK"></div></pre><p>This will work, but OOP suggests that we should try to stay close to real-world logic. So, we can make a class Shape as a parent class and then make separate classes like Square and Rectangle as child classes. This will make the code easier to maintain, and if you plan to add anything new in the future, then you can add that in the child class. To implement this feature, we need to use Abstract Classes. Abstract classes in C++ need at least one <strong>pure virtual function</strong> in a class. The classes that inherit the abstract class must define the pure virtual function; otherwise, the subclass will become an abstract class.</p></section> <section class="main"><h2 id="restrictions-on-abstract-classes" level="2">Restrictions on Abstract Classes</h2><p>There are some restrictions on abstract classes in C++.</p><p>Abstract classes cannot be used for the following –</p><ul> <li>Variables or member data</li> <li>Argument types</li> <li>Function return types</li> <li>Types of explicit conversions.</li> </ul><p>The constructors of the abstract class in c++ can call other member functions, but if they directly or indirectly call the pure virtual function, then the result is undefined.</p><p>But wait! What is a pure virtual function anyway?</p><p>To understand the <strong>pure virtual function</strong>, first, let’s understand virtual functions.</p><p>A <a href="https://www.scaler.com/topics/virtual-function-in-cpp/" target="_blank" title=""><strong>virtual function in C++</strong></a> is a member function declared within a base class and redefined by the derived class.</p><p>A <strong>pure virtual function (or abstract function)</strong> is a virtual function with no definition/logic. It is declared by assigning 0 at the time of declaration.</p><p>Let’s take a look at an example that will make things clear.</p><pre><div class="code-box_snippetContainer__cJ6zK"></div></pre><p><strong>Output –</strong></p><pre><div class="code-box_snippetContainer__cJ6zK"></div></pre><p>In the above code, you can see that the function <span class="highlight--red">perimeter()</span> is a pure virtual function, the <strong>“virtual”</strong> keyword is used, and it is assigned a value of 0.</p><p>In the derived classes, <strong>Rectangle</strong> and <strong>Shape</strong> redefine the pure virtual function.</p></section> <section class="main"><h2 id="characteristics-of-abstract-class-in-c--" level="2">Characteristics of Abstract Class in C++</h2><ol> <li>Abstract Classes must have at least one pure virtual function.</li> </ol><pre><div class="code-box_snippetContainer__cJ6zK"></div></pre><ol start="2"> <li>Abstract Classes cannot be instantiated, but pointers and references of Abstract Class types can be created. You cannot create an object of an abstract class. Here is an example of a pointer to an abstract class.</li> </ol><pre><div class="code-box_snippetContainer__cJ6zK"></div></pre><p><strong>Output –</strong></p><pre><div class="code-box_snippetContainer__cJ6zK"></div></pre><ol start="3"> <li>Abstract Classes are mainly used for <strong>Upcasting</strong>, which means its derived classes can use its interface.</li> <li>Classes that inherit the Abstract Class must implement all pure virtual functions. If they do not, those classes will also be treated as abstract classes.</li> </ol></section> <section class="main"><h2 id="why-can’t-we-make-an-abstract-class-object-" level="2">Why Can’t We Make an Abstract Class Object?</h2><p>Abstract classes in C++ cannot be instantiated because they are “abstract”. It’s like someone is telling you to draw an animal without telling you which specific animal. You can only draw if the person asks you to draw a cat, dog, etc., but an animal is abstract.</p><p>The same is the case with abstract classes in C++, so we can’t create objects, but we can create a pointer of an abstract class.</p></section> <section class="summary"><h2 id="conclusion" level="2">Conclusion</h2><p>Through this article, you now know:</p><ul> <li>What is Abstract Class in C++?</li> <li>What is Inheritance?</li> <li>What is Abstraction?</li> <li>How to create and work with Abstract Class in C++?</li> <li>What are virtual functions, and what is the difference between virtual and pure virtual functions?</li> </ul><p>That’s all for now, folks!</p><p>Thanks for reading.</p></section></div></div></div></div><div class="view_right_section__M6YCz relative p-b-m"></div></div></div><footer><div class="full-width feedback_container__imOut"><div role="button" tabindex="0" class="signin-alert-popup_signInWrapper__Kr4eW"><div class="signin-alert-popup_overLay__Xq3de"></div><div class="row flex-c feedback_feedback_container__YUVyH"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/suggestion_bulb.svg" alt="topics" width="24" height="24" loading="lazy"/><div class="feedback_description__POrxt">Got suggestions?<!-- --> <a class="Tappable-module_root__N7ll5 topics_link feedback_highlighted_text_bottom__CBT21">We would love to hear your feedback.</a></div></div></div></div><div><div class="sidebar_sidebar_ui__IJWgB hide-in-tablet feedback_feedback_content__e6Ole"><div class="feedback_form_container__0L_1Q"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/filled_bulb_pink.svg" alt="topics" width="48" height="48" loading="lazy"/><span class="feedback_feedback_form_text___aJ6l">Your feedback is important to help us improve</span><form class="p-v-10"><textarea placeholder="Your question and comment here" name="feedback" class="feedback_feedback_form__RcrvD"></textarea></form></div><div class="feedback_btn_container__PVJpo"><a class="Tappable-module_root__N7ll5 feedback_btn_effect__U_NEY"><span class="feedback_close_btn__LOmia">Close</span></a><a class="Tappable-module_root__N7ll5 Tappable-module_disabled__XhpfV topics_btn feedback_submit_btn_effect__m1pbm feedback_submit_btn__YzwTC"><span>Submit</span> <svg fill="currentColor" class="icons_icon_arrow__2GBht icons_icon_arrow__right__WUCHP m-l-5" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M5.313 16l10.688-10.688 10.688 10.688-1.938 1.875-7.438-7.438v16.25h-2.625v-16.25l-7.5 7.438z"></path></svg></a></div></div></div><div class="Footer_footer_main__jhKFJ"><div class="Footer_footer_container__0Gbr1"><div class="Footer_scaler_topics_container__NhfHg"><div class="row flex-ac Footer_scaler_topics__x_37L"><a href="https://www.scaler.com/topics/"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/logo.svg" alt="topics logo" width="53" height="40" loading="lazy"/></a><div class="Footer_separator___ExiD"></div><div class="Footer_about_scaler_topic__xVnKx"><div class="bold">A Free learning platform</div><div class="row flex-ac">made with  <img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/icon_heart.svg" alt="heart icon" width="16" height="16" loading="lazy"/>   by  <a href="https://www.scaler.com/?utm_source=topics&amp;utm_medium=footer"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/scaler_logo.svg" alt="scaler logo" width="60" height="8" loading="lazy"/></a></div></div></div><div class="row wrap flex-ac Footer_social_media_icons__Cmgt6"><a href="https://www.instagram.com/scaler_official/" target="_blank" rel="noreferrer"><div class="row Footer_social_media_bubble__AMyOI"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/instagram_footer.svg" alt="Instagram" loading="lazy"/></div></a><a href="https://www.youtube.com/c/SCALER" target="_blank" rel="noreferrer"><div class="row Footer_social_media_bubble__AMyOI"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/youtube_footer.svg" alt="Youtube" loading="lazy"/></div></a><a href="https://twitter.com/scaler_official" target="_blank" rel="noreferrer"><div class="row Footer_social_media_bubble__AMyOI"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/new_twitter.svg" alt="Twitter" loading="lazy"/></div></a><a href="https://www.facebook.com/scalerofficial" target="_blank" rel="noreferrer"><div class="row Footer_social_media_bubble__AMyOI"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/fb_footer.svg" alt="Facebook" loading="lazy"/></div></a><a href="https://www.linkedin.com/school/scalerofficial/mycompany/" target="_blank" rel="noreferrer"><div class="row Footer_social_media_bubble__AMyOI"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/linkedin_footer.svg" alt="Linkedin" loading="lazy"/></div></a><a href="https://discord.com/invite/gD2ZTC5j8K" target="_blank" rel="noreferrer"><div class="row Footer_social_media_bubble__AMyOI"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/discord_footer.svg" alt="Discord" loading="lazy"/></div></a></div></div><div class="Footer_explore_container__EfzLo"><div class="Footer_footer__column__xAs3n"><div class="Footer_footer__heading__f3vN5">Explore Scaler</div><div class="Footer_underLineClassName__gYjXL"></div><ul class="Footer_footer__contents__4EKIb"><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="https://www.scaler.com/academy/?utm_source=topics&amp;utm_medium=footer" target="_blank" rel="noreferrer">Academy</a></li><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="https://www.scaler.com/data-science-course/?utm_source=topics&amp;utm_medium=footer" target="_blank" rel="noreferrer">Data Science &amp; ML</a></li><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="https://www.scaler.com/neovarsity/?utm_source=topics&amp;utm_medium=footer" target="_blank" rel="noreferrer">Neovarsity</a></li></ul></div><div class="Footer_footer__column__xAs3n"><div class="Footer_footer__heading__f3vN5">Explore Topics</div><div class="Footer_underLineClassName__gYjXL"></div><ul class="Footer_footer__contents__4EKIb"><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="/topics/courses/">Free Online Courses</a></li><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="/topics/challenges/">Challenges</a></li><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="/topics/contests/">Contest</a></li><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="/topics/hubs/">Topics</a></li><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="/topics/articles/">Articles</a></li><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="/topics/events/">Events</a></li></ul></div><div class="Footer_footer__column__xAs3n"><div class="Footer_footer__heading__f3vN5">Resources</div><div class="Footer_underLineClassName__gYjXL"></div><ul class="Footer_footer__contents__4EKIb"><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="https://www.scaler.com/about/?utm_source=topics&amp;utm_medium=footer">About Us</a></li><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="https://www.scaler.com/blog/?utm_source=topics&amp;utm_medium=footer">Blog</a></li><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="https://www.scaler.com/careers/?utm_source=topics&amp;utm_medium=footer">Careers</a></li><li class="Footer_footer__list___R5w0"><a class="Footer_footer__link__PbMJQ" href="https://www.scaler.com/review/?utm_source=topics&amp;utm_medium=footer">Review</a></li></ul></div></div><div class="Footer_download_app_container__7I8po"><div class="row flex-ac wrap Footer_download_heading_text__0unCX"><div class="bold">Download the  </div><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/scaler_logo.svg" alt="scaler logo" width="112.5" height="15" loading="lazy"/><div class="bold">app!</div></div><div class="Footer_download_subheading_text__b2GAe">Get all scaler resources under one roof!</div><div class="Footer_download_container__ZVMHW"><div><div class="row m-b-xs"><div class="column flex-c"><div class="row flex-ac Footer_rating__85Peu">4.4<svg fill="currentColor" class="Footer_rating__star__IOBaM" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32"><path d="M7.569 30.625c-0.335 0-0.667-0.103-0.949-0.309-0.529-0.382-0.775-1.039-0.631-1.675l1.963-8.65-6.659-5.84c-0.489-0.427-0.676-1.104-0.475-1.724 0.201-0.618 0.747-1.056 1.395-1.115l8.811-0.8 3.485-8.153c0.257-0.599 0.843-0.986 1.492-0.986 0.651 0 1.235 0.386 1.492 0.983l3.484 8.155 8.81 0.8c0.649 0.058 1.195 0.497 1.397 1.115 0.201 0.619 0.014 1.296-0.476 1.724l-6.659 5.839 1.964 8.651c0.144 0.636-0.102 1.293-0.63 1.675-0.527 0.381-1.229 0.411-1.783 0.078l-7.598-4.541-7.598 4.543c-0.257 0.153-0.544 0.23-0.832 0.23z"></path></svg></div><div class="Footer_rating__subtext__FS9tD">1.71 K Reviews</div></div><div class="Footer_rating__separator__uK_xK"></div><div class="column flex-c"><div class="row flex-ac Footer_rating__85Peu">100K+</div><div class="Footer_rating__subtext__FS9tD">Downloads</div></div></div><div class="row"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/qr_codes/topics_footer_web.svg" alt="QR Code" width="48" height="48" class="Footer_qr_code__F2XYl" loading="lazy"/><div class="Footer_download_subsection__SvcVD"><a href="https://app.scaler.com/XBSh"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/playstore.svg" alt="Playstore Icon" width="92" height="28" class="Footer_mobile_spacer__Jt_yy" loading="lazy"/></a></div></div></div><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/app_download_phone.webp" alt="Playstore Icon" width="130" height="130" class="Footer_download_app_phone__38Crd" loading="lazy"/></div><a href="https://app.scaler.com/Yhwr"><img src="https://d1g0iq4cbcvjcd.cloudfront.net/topics/images/playstore.svg" alt="Playstore Icon" width="92" height="28" class="full-width row flex-ac Footer_mobile_spacer__Jt_yy Footer_mobile_playstore_icon__Dxy6L" loading="lazy"/></a></div></div><div class="Footer_horizontal_separator__72YMO"></div><div class="Footer_seo_container__LpX49"><div class="Footer_seo_heading__F__ls">Popular Free Certification Courses</div><div class="full-width row wrap m-t-xxs Footer_mobile_link_display__A2mzt"><div class="row flex-ac"><a href="https://www.scaler.com/topics/course/java-beginners/" title="Free Java Course Online" class="Footer_link_title__iX4E6">Java Course for Beginners</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/course/cpp-beginners/" title="Free C++ Course Online" class="Footer_link_title__iX4E6">C++ Course with Certificate</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/course/python-for-beginners/" title="Free Python Course Online" class="Footer_link_title__iX4E6">Python Course for Beginners</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/course/javascript-beginners/" title="Free Javascript Course Online" class="Footer_link_title__iX4E6">Javascript Free Course for Beginners</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/course/python-for-data-science/" title="Free Data Science Course Online" class="Footer_link_title__iX4E6">Data Science Course for Beginners</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/course/dbms/" title="Free DBMS Course Online" class="Footer_link_title__iX4E6">DBMS Course</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/course/python-sql-data-science/" title="Free Python for Data Science Course Online" class="Footer_link_title__iX4E6">Python and SQL for Data Science Course</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/course/dsa-interviews-java/" title="Free DSA Java Interview Questions Online" class="Footer_link_title__iX4E6">DSA Problem Solving for Interviews</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/course/instagram-system-design/" title="Free Instagram Design Course Online" class="Footer_link_title__iX4E6">Instagram System Design Course</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/course/dynamic-programming/" title="Free Dynamic Programming Course Online" class="Footer_link_title__iX4E6">Dynamic Programming Course</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/courses/" title="All Free Online Courses" class="Footer_link_title__iX4E6">All Free Online Courses</a></div></div></div><div class="Footer_seo_container__LpX49"><div class="Footer_seo_heading__F__ls">Popular Tutorials</div><div class="full-width row wrap m-t-xxs Footer_mobile_link_display__A2mzt"><div class="row flex-ac"><a href="https://www.scaler.com/topics/python/" title="Python Tutorial Online" class="Footer_link_title__iX4E6">Python Tutorial</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/java/" title="Java Tutorial Online" class="Footer_link_title__iX4E6">Java Tutorial</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/dbms/" title="DBMS Tutorial Online" class="Footer_link_title__iX4E6">DBMS Tutorial</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/javascript/" title="Javascript Tutorial Online" class="Footer_link_title__iX4E6">Javascript Tutorial</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/cpp/" title="C++ Tutorial Online" class="Footer_link_title__iX4E6">C++ Tutorial</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/sql/" title="SQL Tutorial Online" class="Footer_link_title__iX4E6">SQL Tutorial</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/software-engineering/" title="Software Engineering Tutorial Online" class="Footer_link_title__iX4E6">Software Engineering Tutorial</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/data-science/" title="Data Science Tutorial Online" class="Footer_link_title__iX4E6">Data Science Tutorial</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/pandas/" title="Pandas Tutorial Online" class="Footer_link_title__iX4E6">Pandas Tutorial</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/deep-learning/" title="Deep Learning Tutorial Online" class="Footer_link_title__iX4E6">Deep Learning Tutorial</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/hubs/" title="All Tutorials" class="Footer_link_title__iX4E6">All Tutorials</a></div></div></div><div class="Footer_seo_container__LpX49"><div class="Footer_seo_heading__F__ls">Compilers</div><div class="full-width row wrap m-t-xxs Footer_mobile_link_display__A2mzt"><div class="row flex-ac"><a href="https://www.scaler.com/topics/python/online-python-compiler/" title="Python Compiler Online" class="Footer_link_title__iX4E6">Python Compiler</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/java/online-java-compiler/" title="Java Compiler Online" class="Footer_link_title__iX4E6">Java Compiler</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/javascript/online-javascript-compiler/" title="Javascript Compiler Online" class="Footer_link_title__iX4E6">Javascript Compiler</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/c/online-c-compiler/" title="C Compiler Online" class="Footer_link_title__iX4E6">C Compiler</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/cpp/online-cpp-compiler/" title="C++ Compiler Online" class="Footer_link_title__iX4E6">C++ Compiler</a></div></div></div><div class="Footer_seo_container__LpX49"><div class="Footer_seo_heading__F__ls">Tools</div><div class="full-width row wrap m-t-xxs Footer_mobile_link_display__A2mzt"><div class="row flex-ac"><a href="https://www.scaler.com/topics/javascript/json-validator/" title="Json Validator Online" class="Footer_link_title__iX4E6">Json Validator</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/sql/sql-formatter/" title="SQL Formatter Online" class="Footer_link_title__iX4E6">SQL Formatter</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/tools/xml-formatter/" title="XML Formatter Online" class="Footer_link_title__iX4E6">XML Formatter</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/css/css-formatter/" title="CSS Formatter Online" class="Footer_link_title__iX4E6">CSS Formatter</a><span class="Footer_seo_separator__FOJzU"></span></div><div class="row flex-ac"><a href="https://www.scaler.com/topics/javascript/javascript-formatter/" title="JavaScript Formatter Online" class="Footer_link_title__iX4E6">JavaScript Formatter</a></div></div></div><div class="full-width column flex-c Footer_seo_container__LpX49"><div class="m-t-xxs Footer_links__29v39 Footer_copyright__YJEl8"><div>Copyright <!-- -->2025<!-- --> InterviewBit Technologies Pvt. Ltd. All Rights Reserved.</div></div><div class="row flex-ac m-t-xxs Footer_links__29v39"><a href="https://www.scaler.com/privacy/?utm_source=topics&amp;utm_medium=footer">Privacy Policy</a><div class="Footer_link_separator__rUm4Q"></div><a href="https://www.scaler.com/terms/?utm_source=topics&amp;utm_medium=footer">Terms of Use</a><div class="Footer_link_separator__rUm4Q"></div><a href="https://www.scaler.com/contact/?utm_source=topics&amp;utm_medium=footer">Contact Us</a></div></div></div></footer></main></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{"propsReq":{"pageClass":"no-border","articleInfo":{"article":{"title":"Abstract Class in C++","slug":"abstract-class-in-cpp","published_at":"2021-09-27T00:00:00.000Z","last_updated_at":"2024-01-04T08:08:26.000Z","read_time":3,"description":"Learn about Abstract Class in C++.","cover_image_alt":"Abstract Class in C++","cover_image":"https://www.scaler.com/topics/images/abstract-class-in-cpp.webp","cover_image_thumbnail":"https://www.scaler.com/topics/images/abstract-class-in-cpp_thumbnail.webp","popular":false,"views_count":622,"words_count":689,"quiz_id":132249,"quiz_pops":[],"content":"---\ntitle: Abstract Class in C++ - Scaler Topics\ndescription: Abstract class in C++ refer to classes containing at least one pure virtual function, which cannot be instantiated. Such classes are mainly used for Upcasting.\nauthor: Shubh Agarwal\ncategory: C++\n---\n\n\n\n\n\n:::section{.main}\nIn C++, an abstract class is defined by having at least one pure virtual function, a function without a concrete definition. These classes are essential in object-oriented programming, structuring code to mirror real-life scenarios through inheritance and abstraction. Abstract classes, which cannot be instantiated, are pivotal for expressing broad concepts and upcasting, allowing derived classes to implement their interfaces. Utilize pointers and references for abstract class types, and remember that any subclass failing to define the pure virtual function becomes abstract itself. The virtual function is declared with the pure specifier (= 0).\n\n## Abstract Class in C++ Example\nLet’s say we are making a calculator which returns the perimeter of the shape we put in. Think of what kind of code you would write for such a calculator. You might start with some initial shapes and hardcode the perimeter by making separate functions inside the Shape class.\n\nThe class might look something like this –\n\n```cpp\nclass Shape {\n public:\n // All the functions of both square and rectangle are clubbed together in a single class.\n void width(int w) {\n shape_width = w;\n }\n void height(int h) {\n shape_height = h;\n }\n int perimeterOfSquare(int s) {\n return 4 * s;\n }\n int perimeterOfRectange(int l, int b) {\n return 2 * (l + b);\n }\n \n protected:\n int shape_width;\n int shape_height;\n};\n```\nThis will work, but OOP suggests that we should try to stay close to real-world logic. So, we can make a class Shape as a parent class and then make separate classes like Square and Rectangle as child classes. This will make the code easier to maintain, and if you plan to add anything new in the future, then you can add that in the child class. To implement this feature, we need to use Abstract Classes. Abstract classes in C++ need at least one **pure virtual function** in a class. The classes that inherit the abstract class must define the pure virtual function; otherwise, the subclass will become an abstract class.\n\n:::\n\n:::section{.main}\n## Restrictions on Abstract Classes\nThere are some restrictions on abstract classes in C++.\n\nAbstract classes cannot be used for the following –\n\n* Variables or member data\n* Argument types\n* Function return types\n* Types of explicit conversions.\n\nThe constructors of the abstract class in c++ can call other member functions, but if they directly or indirectly call the pure virtual function, then the result is undefined.\n\nBut wait! What is a pure virtual function anyway?\n\nTo understand the **pure virtual function**, first, let’s understand virtual functions.\n\nA [**virtual function in C++**](https://www.scaler.com/topics/virtual-function-in-cpp/) is a member function declared within a base class and redefined by the derived class.\n\nA **pure virtual function (or abstract function)** is a virtual function with no definition/logic. It is declared by assigning 0 at the time of declaration.\n\nLet’s take a look at an example that will make things clear.\n\n```cpp\n#include\u003ciostream\u003e\nusing namespace std;\n\n// Shape class.\nclass Shape {\n public:\n \n // Function to calculate the parameter, declared as pure virtual, so all the derived classes necessarily need to implement this.\n virtual int perimeter() = 0;\n void width(int w) {\n shape_width = w;\n }\n void height(int h) {\n shape_height = h;\n }\n \n protected:\n int shape_width;\n int shape_height;\n};\n\nclass Rectangle: public Shape {\n public: \n // Class Rectangle provided implementation of perimeter() function.\n int perimeter() {\n return (2 * (shape_width + shape_height));\n }\n};\n\nclass Square: public Shape {\n public: \n // Class Square provided implementation of perimeter() function.\n int perimeter() {\n return (4 * shape_width);\n }\n};\n\nint main() {\n Rectangle R;\n Square S;\n\n R.width(10);\n R.height(5);\n S.width(10);\n\n cout \u003c\u003c \"Perimeter of Rectangle: \" \u003c\u003c R.perimeter() \u003c\u003c endl;\n cout \u003c\u003c \"Perimeter of Square: \" \u003c\u003c S.perimeter() \u003c\u003c endl;\n return 0;\n}\n```\n**Output –** \n```plaintext\nPerimeter of Rectangle : 30\nPerimeter of Square: 40\n```\nIn the above code, you can see that the function `perimeter()` is a pure virtual function, the **“virtual”** keyword is used, and it is assigned a value of 0.\n\nIn the derived classes, **Rectangle** and **Shape** redefine the pure virtual function.\n\n:::\n\n:::section{.main}\n## Characteristics of Abstract Class in C++\n1. Abstract Classes must have at least one pure virtual function.\n\n```cpp\nvirtual int perimeter() = 0;\n```\n2. Abstract Classes cannot be instantiated, but pointers and references of Abstract Class types can be created. You cannot create an object of an abstract class.\nHere is an example of a pointer to an abstract class.\n\n```cpp\n#include\u003ciostream\u003e\nusing namespace std;\n\nclass Base {\n public:\n virtual void print() = 0;\n};\n\nclass Derived: public Base {\n public: \n void print() {\n cout \u003c\u003c \"This is from the derived class \\n\";\n }\n};\n\nint main(void) {\n Base* basePointer = new Derived();\n basePointer -\u003e print();\n return 0;\n}\n```\n**Output –** \n```plaintext\nThis is from the derived class\n```\n3. Abstract Classes are mainly used for **Upcasting**, which means its derived classes can use its interface.\n4. Classes that inherit the Abstract Class must implement all pure virtual functions. If they do not, those classes will also be treated as abstract classes.\n\n:::\n\n:::section{.main}\n## Why Can’t We Make an Abstract Class Object?\nAbstract classes in C++ cannot be instantiated because they are “abstract”. It’s like someone is telling you to draw an animal without telling you which specific animal. You can only draw if the person asks you to draw a cat, dog, etc., but an animal is abstract.\n\nThe same is the case with abstract classes in C++, so we can’t create objects, but we can create a pointer of an abstract class.\n\n:::\n\n:::section{.summary}\n## Conclusion\nThrough this article, you now know:\n\n* What is Abstract Class in C++?\n* What is Inheritance?\n* What is Abstraction?\n* How to create and work with Abstract Class in C++?\n* What are virtual functions, and what is the difference between virtual and pure virtual functions?\n\nThat’s all for now, folks! \n\nThanks for reading. \n\n\n:::\n","course_video_data":[],"collaborators":{"authors":[{"name":"Shubh Agrawal","slug":"57c1eae984a4","email":"shubhagrawal4457@gmail.com","image":"https://lh3.googleusercontent.com/a/ACg8ocKvUSQlg-znPsLLVFhkdJIbRbn-RTp3G3gaOho6dFqFrvU=s96-c","linkedin_profile":"https://www.linkedin.com/in/theshubhagrwl/","company":"Superlayer.io","designation":"Full Stack Developer Intern","validated_at":"2024-02-22T13:23:29.000Z","topics_slug":"shubh-agrawal","about":"Shubh Agrawal, a skilled Frontend Engineer, seamlessly combines creativity and technical prowess in crafting visually appealing and user-centric web interfaces. With a keen eye for design and a strong coding acumen, Shubh contributes to the seamless integration of form and function in the digital landscape.","github_profile":null,"twitter_profile":null,"headline":"Frontend Engineer"}],"co_authors":[{"name":"Mehul Mathur","slug":"b21cebee1f72","email":"mehul.mathur@scaler.com","image":null,"linkedin_profile":"https://www.linkedin.com/in/mehul-mathur-962b1a193/","company":"Scaler Academy","designation":"SDE - Intern","validated_at":null,"topics_slug":"mehul-mathur","about":null,"github_profile":null,"twitter_profile":null,"headline":null}],"reviewers":[],"fact_checkers":[]},"tags":[{"title":"C++","slug":"cpp"}],"programs":["academy","programming_languages"]},"treeMap":{"-1":{"slug":"-1","title":"","read":false,"current":false,"isExpanded":false,"link":"","children":["module_the-history-of-c","module_mechanism-of-creating-a-programme-in-c","module_programme-structure-and-best-practices-in-c","module_data-dealing-in-c","module_control-flow-in-c","module_functions-in-c-efe9e6ef-9a1a-4444-b747-1171ed867c44","module_pointers-and-references-in-c","module_compound-data-types-in-c","module_storage-classes-in-c","module_object-oriented-programming","module_advance-concepts-of-oops","module_stl","module_miscellaneous"],"parent":"","prev":"","next":"","image":null},"module_the-history-of-c":{"slug":"module_the-history-of-c","title":"The History of C++","read":false,"current":false,"isExpanded":false,"link":"","children":["origin-and-philosophy-of-cpp","difference-between-c-and-cplusplus"],"parent":"-1","prev":"","next":"","image":null},"origin-and-philosophy-of-cpp":{"slug":"origin-and-philosophy-of-cpp","title":"C++ Origin and philosophy - History of C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/origin-and-philosophy-of-cpp/","children":[],"parent":"module_the-history-of-c","prev":"","next":"difference-between-c-and-cplusplus","image":null},"difference-between-c-and-cplusplus":{"slug":"difference-between-c-and-cplusplus","title":"Difference Between C and C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/difference-between-c-and-cplusplus/","children":[],"parent":"module_the-history-of-c","prev":"origin-and-philosophy-of-cpp","next":"cpp-environment-setup","image":null},"module_mechanism-of-creating-a-programme-in-c":{"slug":"module_mechanism-of-creating-a-programme-in-c","title":"Mechanism of Creating a Programme in C++ ","read":false,"current":false,"isExpanded":false,"link":"","children":["cpp-environment-setup"],"parent":"-1","prev":"","next":"","image":null},"cpp-environment-setup":{"slug":"cpp-environment-setup","title":"C++ Environment Setup","read":false,"current":false,"isExpanded":false,"link":"/cpp/cpp-environment-setup/","children":[],"parent":"module_mechanism-of-creating-a-programme-in-c","prev":"difference-between-c-and-cplusplus","next":"comments-in-cpp","image":null},"module_programme-structure-and-best-practices-in-c":{"slug":"module_programme-structure-and-best-practices-in-c","title":"Programme Structure and Best Practices in C++","read":false,"current":false,"isExpanded":false,"link":"","children":["comments-in-cpp","cpp-header-files","namespace-in-cpp","cpp-coding-standards","statements-in-cpp"],"parent":"-1","prev":"","next":"","image":null},"comments-in-cpp":{"slug":"comments-in-cpp","title":"C++ Comments and C-style Comment in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/comments-in-cpp/","children":[],"parent":"module_programme-structure-and-best-practices-in-c","prev":"cpp-environment-setup","next":"cpp-header-files","image":null},"cpp-header-files":{"slug":"cpp-header-files","title":"C++ Header Files","read":false,"current":false,"isExpanded":false,"link":"/cpp/cpp-header-files/","children":[],"parent":"module_programme-structure-and-best-practices-in-c","prev":"comments-in-cpp","next":"namespace-in-cpp","image":null},"namespace-in-cpp":{"slug":"namespace-in-cpp","title":"Namespaces in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/namespace-in-cpp/","children":[],"parent":"module_programme-structure-and-best-practices-in-c","prev":"cpp-header-files","next":"cpp-coding-standards","image":null},"cpp-coding-standards":{"slug":"cpp-coding-standards","title":"C++ Coding Standards","read":false,"current":false,"isExpanded":false,"link":"/cpp/cpp-coding-standards/","children":[],"parent":"module_programme-structure-and-best-practices-in-c","prev":"namespace-in-cpp","next":"statements-in-cpp","image":null},"statements-in-cpp":{"slug":"statements-in-cpp","title":"Statements in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/statements-in-cpp/","children":[],"parent":"module_control-flow-in-c","prev":"expressions-in-cpp","next":"loop-in-cpp","image":null},"module_data-dealing-in-c":{"slug":"module_data-dealing-in-c","title":"Data Dealing in C++","read":false,"current":false,"isExpanded":false,"link":"","children":["data-types-in-cpp","modifiers-in-cpp","constants-in-cpp","keywords-in-cpp","variables-in-c-plus-plus","auto-in-cpp","difference-between-unicode-and-ascii","binary-representation-of-a-number","type-conversion-in-cpp","operators-in-cpp","expressions-in-cpp"],"parent":"-1","prev":"","next":"","image":null},"data-types-in-cpp":{"slug":"data-types-in-cpp","title":"Data Types in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/data-types-in-cpp/","children":[],"parent":"module_data-dealing-in-c","prev":"statements-in-cpp","next":"modifiers-in-cpp","image":null},"modifiers-in-cpp":{"slug":"modifiers-in-cpp","title":"Modifiers in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/modifiers-in-cpp/","children":[],"parent":"module_data-dealing-in-c","prev":"data-types-in-cpp","next":"constants-in-cpp","image":null},"constants-in-cpp":{"slug":"constants-in-cpp","title":"Constants in c++","read":false,"current":false,"isExpanded":false,"link":"/cpp/constants-in-cpp/","children":[],"parent":"module_data-dealing-in-c","prev":"modifiers-in-cpp","next":"keywords-in-cpp","image":null},"keywords-in-cpp":{"slug":"keywords-in-cpp","title":"Keywords in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/keywords-in-cpp/","children":[],"parent":"module_data-dealing-in-c","prev":"constants-in-cpp","next":"variables-in-c-plus-plus","image":null},"variables-in-c-plus-plus":{"slug":"variables-in-c-plus-plus","title":"Variables in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/variables-in-c-plus-plus/","children":[],"parent":"module_data-dealing-in-c","prev":"keywords-in-cpp","next":"auto-in-cpp","image":null},"auto-in-cpp":{"slug":"auto-in-cpp","title":"Auto in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/auto-in-cpp/","children":[],"parent":"module_data-dealing-in-c","prev":"variables-in-c-plus-plus","next":"difference-between-unicode-and-ascii","image":null},"difference-between-unicode-and-ascii":{"slug":"difference-between-unicode-and-ascii","title":"Difference Between UNICODE and ASCII","read":false,"current":false,"isExpanded":false,"link":"/cpp/difference-between-unicode-and-ascii/","children":[],"parent":"module_data-dealing-in-c","prev":"auto-in-cpp","next":"binary-representation-of-a-number","image":null},"binary-representation-of-a-number":{"slug":"binary-representation-of-a-number","title":"Binary Representation of A Given Number in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/binary-representation-of-a-number/","children":[],"parent":"module_data-dealing-in-c","prev":"difference-between-unicode-and-ascii","next":"type-conversion-in-cpp","image":null},"type-conversion-in-cpp":{"slug":"type-conversion-in-cpp","title":"Type Conversion in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/type-conversion-in-cpp/","children":[],"parent":"module_data-dealing-in-c","prev":"binary-representation-of-a-number","next":"operators-in-cpp","image":null},"operators-in-cpp":{"slug":"operators-in-cpp","title":"Operators in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/operators-in-cpp/","children":[],"parent":"module_data-dealing-in-c","prev":"type-conversion-in-cpp","next":"expressions-in-cpp","image":null},"expressions-in-cpp":{"slug":"expressions-in-cpp","title":"Expressions in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/expressions-in-cpp/","children":[],"parent":"module_data-dealing-in-c","prev":"operators-in-cpp","next":"statements-in-cpp","image":null},"module_control-flow-in-c":{"slug":"module_control-flow-in-c","title":"Control Flow in C++","read":false,"current":false,"isExpanded":false,"link":"","children":["statements-in-cpp","loop-in-cpp","jump-statement-in-cpp"],"parent":"-1","prev":"","next":"","image":null},"loop-in-cpp":{"slug":"loop-in-cpp","title":"Loop in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/loop-in-cpp/","children":[],"parent":"module_control-flow-in-c","prev":"statements-in-cpp","next":"jump-statement-in-cpp","image":null},"jump-statement-in-cpp":{"slug":"jump-statement-in-cpp","title":"Jump Statement in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/jump-statement-in-cpp/","children":[],"parent":"module_control-flow-in-c","prev":"loop-in-cpp","next":"functions-in-cpp","image":null},"module_functions-in-c-efe9e6ef-9a1a-4444-b747-1171ed867c44":{"slug":"module_functions-in-c-efe9e6ef-9a1a-4444-b747-1171ed867c44","title":"Functions in C++","read":false,"current":false,"isExpanded":false,"link":"","children":["functions-in-cpp","library-functions-in-cpp","recursion-in-cpp","cpp-preprocessor-directives","adventures-in-functions"],"parent":"-1","prev":"","next":"","image":null},"functions-in-cpp":{"slug":"functions-in-cpp","title":"Functions in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/functions-in-cpp/","children":[],"parent":"module_functions-in-c-efe9e6ef-9a1a-4444-b747-1171ed867c44","prev":"jump-statement-in-cpp","next":"library-functions-in-cpp","image":null},"library-functions-in-cpp":{"slug":"library-functions-in-cpp","title":"Library Functions in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/library-functions-in-cpp/","children":[],"parent":"module_functions-in-c-efe9e6ef-9a1a-4444-b747-1171ed867c44","prev":"functions-in-cpp","next":"recursion-in-cpp","image":null},"recursion-in-cpp":{"slug":"recursion-in-cpp","title":"C++ Recursion","read":false,"current":false,"isExpanded":false,"link":"/cpp/recursion-in-cpp/","children":[],"parent":"module_functions-in-c-efe9e6ef-9a1a-4444-b747-1171ed867c44","prev":"library-functions-in-cpp","next":"cpp-preprocessor-directives","image":null},"cpp-preprocessor-directives":{"slug":"cpp-preprocessor-directives","title":"Preprocessor Directives in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/cpp-preprocessor-directives/","children":[],"parent":"module_functions-in-c-efe9e6ef-9a1a-4444-b747-1171ed867c44","prev":"recursion-in-cpp","next":"adventures-in-functions","image":null},"adventures-in-functions":{"slug":"adventures-in-functions","title":"More about functions in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/adventures-in-functions/","children":[],"parent":"module_functions-in-c-efe9e6ef-9a1a-4444-b747-1171ed867c44","prev":"cpp-preprocessor-directives","next":"pointers-in-cpp","image":null},"module_pointers-and-references-in-c":{"slug":"module_pointers-and-references-in-c","title":"Pointers and References in C++","read":false,"current":false,"isExpanded":false,"link":"","children":["pointers-in-cpp","pointers-vs-references-in-cplusplus","opaque-pointer-in-cpp","smart-pointers-in-cpp","pointer-to-pointer-cpp","functions-with-variable-number-of-arguments-in-cpp","complex-declarations-in-cpp","function-pointer-cpp"],"parent":"-1","prev":"","next":"","image":null},"pointers-in-cpp":{"slug":"pointers-in-cpp","title":"Pointers in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/pointers-in-cpp/","children":[],"parent":"module_pointers-and-references-in-c","prev":"adventures-in-functions","next":"pointers-vs-references-in-cplusplus","image":null},"pointers-vs-references-in-cplusplus":{"slug":"pointers-vs-references-in-cplusplus","title":"Pointers vs References in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/pointers-vs-references-in-cplusplus/","children":[],"parent":"module_pointers-and-references-in-c","prev":"pointers-in-cpp","next":"opaque-pointer-in-cpp","image":null},"opaque-pointer-in-cpp":{"slug":"opaque-pointer-in-cpp","title":"Opaque Pointer in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/opaque-pointer-in-cpp/","children":[],"parent":"module_pointers-and-references-in-c","prev":"pointers-vs-references-in-cplusplus","next":"smart-pointers-in-cpp","image":null},"smart-pointers-in-cpp":{"slug":"smart-pointers-in-cpp","title":"Smart Pointers in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/smart-pointers-in-cpp/","children":[],"parent":"module_pointers-and-references-in-c","prev":"opaque-pointer-in-cpp","next":"pointer-to-pointer-cpp","image":null},"pointer-to-pointer-cpp":{"slug":"pointer-to-pointer-cpp","title":"Pointers to Pointers in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/pointer-to-pointer-cpp/","children":[],"parent":"module_pointers-and-references-in-c","prev":"smart-pointers-in-cpp","next":"functions-with-variable-number-of-arguments-in-cpp","image":null},"functions-with-variable-number-of-arguments-in-cpp":{"slug":"functions-with-variable-number-of-arguments-in-cpp","title":"Functions with Variable Number of Arguments in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/functions-with-variable-number-of-arguments-in-cpp/","children":[],"parent":"module_pointers-and-references-in-c","prev":"pointer-to-pointer-cpp","next":"complex-declarations-in-cpp","image":null},"complex-declarations-in-cpp":{"slug":"complex-declarations-in-cpp","title":"Complex Declarations in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/complex-declarations-in-cpp/","children":[],"parent":"module_pointers-and-references-in-c","prev":"functions-with-variable-number-of-arguments-in-cpp","next":"function-pointer-cpp","image":null},"function-pointer-cpp":{"slug":"function-pointer-cpp","title":"Pointers to Functions in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/function-pointer-cpp/","children":[],"parent":"module_pointers-and-references-in-c","prev":"complex-declarations-in-cpp","next":"array-in-cpp","image":null},"module_compound-data-types-in-c":{"slug":"module_compound-data-types-in-c","title":"Compound Data Types in C++","read":false,"current":false,"isExpanded":false,"link":"","children":["array-in-cpp","strings-in-cpp","union-and-enum-in-Cpp"],"parent":"-1","prev":"","next":"","image":null},"array-in-cpp":{"slug":"array-in-cpp","title":"Array in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/array-in-cpp/","children":[],"parent":"module_compound-data-types-in-c","prev":"function-pointer-cpp","next":"strings-in-cpp","image":null},"strings-in-cpp":{"slug":"strings-in-cpp","title":"Strings in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/strings-in-cpp/","children":[],"parent":"module_compound-data-types-in-c","prev":"array-in-cpp","next":"union-and-enum-in-Cpp","image":null},"union-and-enum-in-Cpp":{"slug":"union-and-enum-in-Cpp","title":"Union and Enum in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/union-and-enum-in-Cpp/","children":[],"parent":"module_compound-data-types-in-c","prev":"strings-in-cpp","next":"storage-classes-in-cpp","image":null},"module_storage-classes-in-c":{"slug":"module_storage-classes-in-c","title":"Storage Classes in C++","read":false,"current":false,"isExpanded":false,"link":"","children":["storage-classes-in-cpp"],"parent":"-1","prev":"","next":"","image":null},"storage-classes-in-cpp":{"slug":"storage-classes-in-cpp","title":"Storage Classes in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/storage-classes-in-cpp/","children":[],"parent":"module_storage-classes-in-c","prev":"union-and-enum-in-Cpp","next":"procedural-programming","image":null},"module_object-oriented-programming":{"slug":"module_object-oriented-programming","title":"Object Oriented Programming","read":false,"current":false,"isExpanded":false,"link":"","children":["procedural-programming","class-and-object-in-cpp","constructor-and-destructor-in-cpp","abstraction-in-cpp","generic-programming-in-cpp","this-pointer-in-cpp","static-member-in-cpp"],"parent":"-1","prev":"","next":"","image":null},"procedural-programming":{"slug":"procedural-programming","title":"Procedural Programming and Object Oriented Programming in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/procedural-programming/","children":[],"parent":"module_object-oriented-programming","prev":"storage-classes-in-cpp","next":"class-and-object-in-cpp","image":null},"class-and-object-in-cpp":{"slug":"class-and-object-in-cpp","title":"Classes and Objects in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/class-and-object-in-cpp/","children":[],"parent":"module_object-oriented-programming","prev":"procedural-programming","next":"constructor-and-destructor-in-cpp","image":null},"constructor-and-destructor-in-cpp":{"slug":"constructor-and-destructor-in-cpp","title":"Constructor and Destructor in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/constructor-and-destructor-in-cpp/","children":[],"parent":"module_object-oriented-programming","prev":"class-and-object-in-cpp","next":"abstraction-in-cpp","image":null},"abstraction-in-cpp":{"slug":"abstraction-in-cpp","title":"Abstraction in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/abstraction-in-cpp/","children":[],"parent":"module_object-oriented-programming","prev":"constructor-and-destructor-in-cpp","next":"generic-programming-in-cpp","image":null},"generic-programming-in-cpp":{"slug":"generic-programming-in-cpp","title":"Generic Programming in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/generic-programming-in-cpp/","children":[],"parent":"module_object-oriented-programming","prev":"abstraction-in-cpp","next":"this-pointer-in-cpp","image":null},"this-pointer-in-cpp":{"slug":"this-pointer-in-cpp","title":"‘this’ Pointer in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/this-pointer-in-cpp/","children":[],"parent":"module_object-oriented-programming","prev":"generic-programming-in-cpp","next":"static-member-in-cpp","image":null},"static-member-in-cpp":{"slug":"static-member-in-cpp","title":"Static Member in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/static-member-in-cpp/","children":[],"parent":"module_object-oriented-programming","prev":"this-pointer-in-cpp","next":"operator-overloading-in-cpp","image":null},"module_advance-concepts-of-oops":{"slug":"module_advance-concepts-of-oops","title":"Advance Concepts of OOPS","read":false,"current":true,"isExpanded":true,"link":"","children":["operator-overloading-in-cpp","friend-function-in-cpp","dynamic-memory-allocation-in-cpp","dynamic-member","inheritance-in-cpp","type-conversions-in-class-hierarchies","polymorphism-in-cpp","abstract-class-in-cpp","multiple-inheritance-in-cpp","templates-in-cpp","exception-handling-in-cpp","file-handling-in-cpp"],"parent":"-1","prev":"","next":"","image":null},"operator-overloading-in-cpp":{"slug":"operator-overloading-in-cpp","title":"Operator Overloading in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/operator-overloading-in-cpp/","children":[],"parent":"module_advance-concepts-of-oops","prev":"static-member-in-cpp","next":"friend-function-in-cpp","image":null},"friend-function-in-cpp":{"slug":"friend-function-in-cpp","title":"Friend Function in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/friend-function-in-cpp/","children":[],"parent":"module_advance-concepts-of-oops","prev":"operator-overloading-in-cpp","next":"dynamic-memory-allocation-in-cpp","image":null},"dynamic-memory-allocation-in-cpp":{"slug":"dynamic-memory-allocation-in-cpp","title":"Dynamic Memory Allocation in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/dynamic-memory-allocation-in-cpp/","children":[],"parent":"module_advance-concepts-of-oops","prev":"friend-function-in-cpp","next":"dynamic-member","image":null},"dynamic-member":{"slug":"dynamic-member","title":"Dynamic Members","read":false,"current":false,"isExpanded":false,"link":"/cpp/dynamic-member/","children":[],"parent":"module_advance-concepts-of-oops","prev":"dynamic-memory-allocation-in-cpp","next":"inheritance-in-cpp","image":null},"inheritance-in-cpp":{"slug":"inheritance-in-cpp","title":"Inheritance in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/inheritance-in-cpp/","children":[],"parent":"module_advance-concepts-of-oops","prev":"dynamic-member","next":"type-conversions-in-class-hierarchies","image":null},"type-conversions-in-class-hierarchies":{"slug":"type-conversions-in-class-hierarchies","title":"Type Conversions in Class Hierarchies","read":false,"current":false,"isExpanded":false,"link":"/cpp/type-conversions-in-class-hierarchies/","children":[],"parent":"module_advance-concepts-of-oops","prev":"inheritance-in-cpp","next":"polymorphism-in-cpp","image":null},"polymorphism-in-cpp":{"slug":"polymorphism-in-cpp","title":"Polymorphism in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/polymorphism-in-cpp/","children":[],"parent":"module_advance-concepts-of-oops","prev":"type-conversions-in-class-hierarchies","next":"abstract-class-in-cpp","image":null},"abstract-class-in-cpp":{"slug":"abstract-class-in-cpp","title":"Abstract Class in C++","read":false,"current":true,"isExpanded":true,"link":"/cpp/abstract-class-in-cpp/","children":[],"parent":"module_advance-concepts-of-oops","prev":"polymorphism-in-cpp","next":"multiple-inheritance-in-cpp","image":null},"multiple-inheritance-in-cpp":{"slug":"multiple-inheritance-in-cpp","title":"Multiple Inheritance in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/multiple-inheritance-in-cpp/","children":[],"parent":"module_advance-concepts-of-oops","prev":"abstract-class-in-cpp","next":"templates-in-cpp","image":null},"templates-in-cpp":{"slug":"templates-in-cpp","title":"Templates in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/templates-in-cpp/","children":[],"parent":"module_advance-concepts-of-oops","prev":"multiple-inheritance-in-cpp","next":"exception-handling-in-cpp","image":null},"exception-handling-in-cpp":{"slug":"exception-handling-in-cpp","title":"Exception Handling in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/exception-handling-in-cpp/","children":[],"parent":"module_advance-concepts-of-oops","prev":"templates-in-cpp","next":"file-handling-in-cpp","image":null},"file-handling-in-cpp":{"slug":"file-handling-in-cpp","title":"File Handling in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/file-handling-in-cpp/","children":[],"parent":"module_advance-concepts-of-oops","prev":"exception-handling-in-cpp","next":"map-in-cpp","image":null},"module_stl":{"slug":"module_stl","title":"STL","read":false,"current":false,"isExpanded":false,"link":"","children":["map-in-cpp","containers-in-cpp","set-in-cpp","multiset-in-cpp","multimap-in-cpp","stack-in-cpp","queue-in-cpp","deque-in-cpp","vector-in-cpp","list-in-cpp","priority-queue-cpp","pair-in-cpp"],"parent":"-1","prev":"","next":"","image":null},"map-in-cpp":{"slug":"map-in-cpp","title":"Map in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/map-in-cpp/","children":[],"parent":"module_stl","prev":"file-handling-in-cpp","next":"containers-in-cpp","image":null},"containers-in-cpp":{"slug":"containers-in-cpp","title":"C++ Container Types and Sequences","read":false,"current":false,"isExpanded":false,"link":"/cpp/containers-in-cpp/","children":[],"parent":"module_stl","prev":"map-in-cpp","next":"set-in-cpp","image":null},"set-in-cpp":{"slug":"set-in-cpp","title":"Set in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/set-in-cpp/","children":[],"parent":"module_stl","prev":"containers-in-cpp","next":"multiset-in-cpp","image":null},"multiset-in-cpp":{"slug":"multiset-in-cpp","title":"Multiset in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/multiset-in-cpp/","children":[],"parent":"module_stl","prev":"set-in-cpp","next":"multimap-in-cpp","image":null},"multimap-in-cpp":{"slug":"multimap-in-cpp","title":"Multimap in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/multimap-in-cpp/","children":[],"parent":"module_stl","prev":"multiset-in-cpp","next":"stack-in-cpp","image":null},"stack-in-cpp":{"slug":"stack-in-cpp","title":"Stack in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/stack-in-cpp/","children":[],"parent":"module_stl","prev":"multimap-in-cpp","next":"queue-in-cpp","image":null},"queue-in-cpp":{"slug":"queue-in-cpp","title":"Queue in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/queue-in-cpp/","children":[],"parent":"module_stl","prev":"stack-in-cpp","next":"deque-in-cpp","image":null},"deque-in-cpp":{"slug":"deque-in-cpp","title":"Deque in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/deque-in-cpp/","children":[],"parent":"module_stl","prev":"queue-in-cpp","next":"vector-in-cpp","image":null},"vector-in-cpp":{"slug":"vector-in-cpp","title":"Vector in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/vector-in-cpp/","children":[],"parent":"module_stl","prev":"deque-in-cpp","next":"list-in-cpp","image":null},"list-in-cpp":{"slug":"list-in-cpp","title":"List in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/list-in-cpp/","children":[],"parent":"module_stl","prev":"vector-in-cpp","next":"priority-queue-cpp","image":null},"priority-queue-cpp":{"slug":"priority-queue-cpp","title":"Priority Queue in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/priority-queue-cpp/","children":[],"parent":"module_stl","prev":"list-in-cpp","next":"pair-in-cpp","image":null},"pair-in-cpp":{"slug":"pair-in-cpp","title":"Pair in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/pair-in-cpp/","children":[],"parent":"module_stl","prev":"priority-queue-cpp","next":"lambda-function-cpp","image":null},"module_miscellaneous":{"slug":"module_miscellaneous","title":"Miscellaneous","read":false,"current":false,"isExpanded":false,"link":"","children":["lambda-function-cpp","lvalue-and-rvalue","concurrent-programming","new-operator-in-cpp","uses-of-cpp"],"parent":"-1","prev":"","next":"","image":null},"lambda-function-cpp":{"slug":"lambda-function-cpp","title":"Lambda Expression in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/lambda-function-cpp/","children":[],"parent":"module_miscellaneous","prev":"pair-in-cpp","next":"lvalue-and-rvalue","image":null},"lvalue-and-rvalue":{"slug":"lvalue-and-rvalue","title":"lvalue and rvalue in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/lvalue-and-rvalue/","children":[],"parent":"module_miscellaneous","prev":"lambda-function-cpp","next":"concurrent-programming","image":null},"concurrent-programming":{"slug":"concurrent-programming","title":"Concurrent Programming and Low-Level Programming","read":false,"current":false,"isExpanded":false,"link":"/cpp/concurrent-programming/","children":[],"parent":"module_miscellaneous","prev":"lvalue-and-rvalue","next":"new-operator-in-cpp","image":null},"new-operator-in-cpp":{"slug":"new-operator-in-cpp","title":"new Operator in C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/new-operator-in-cpp/","children":[],"parent":"module_miscellaneous","prev":"concurrent-programming","next":"uses-of-cpp","image":null},"uses-of-cpp":{"slug":"uses-of-cpp","title":"Uses of C++","read":false,"current":false,"isExpanded":false,"link":"/cpp/uses-of-cpp/","children":[],"parent":"module_miscellaneous","prev":"new-operator-in-cpp","next":"","image":null}},"nextSlug":"multiple-inheritance-in-cpp","prevSlug":"polymorphism-in-cpp","breadcrumb":[{"slug":"/hubs","title":"Reading Tracks","link":"/hubs","type":"reading-track"},{"slug":"cpp","title":"C++ Tutorial","link":"/cpp"},{"slug":"abstract-class-in-cpp","title":"Abstract Class in C++","link":""}],"hubInfo":{"slug":"cpp","title":"C++ Tutorial","eligible_for_certificate":false},"mappedCourseSlug":"cpp-beginners"}},"objectType":"Article","metaDetails":{"title":"Abstract Class in C++ - Scaler Topics","description":"Abstract class in C++ refer to classes containing at least one pure virtual function, which cannot be instantiated. Such classes are mainly used for Upcasting.","author":"Shubh Agarwal","category":"C++","publish_date":"undefined"},"contentData":"\n\n\n\n\n:::section{.main}\nIn C++, an abstract class is defined by having at least one pure virtual function, a function without a concrete definition. These classes are essential in object-oriented programming, structuring code to mirror real-life scenarios through inheritance and abstraction. Abstract classes, which cannot be instantiated, are pivotal for expressing broad concepts and upcasting, allowing derived classes to implement their interfaces. Utilize pointers and references for abstract class types, and remember that any subclass failing to define the pure virtual function becomes abstract itself. The virtual function is declared with the pure specifier (= 0).\n\n## Abstract Class in C++ Example\nLet’s say we are making a calculator which returns the perimeter of the shape we put in. Think of what kind of code you would write for such a calculator. You might start with some initial shapes and hardcode the perimeter by making separate functions inside the Shape class.\n\nThe class might look something like this –\n\n```cpp\nclass Shape {\n public:\n // All the functions of both square and rectangle are clubbed together in a single class.\n void width(int w) {\n shape_width = w;\n }\n void height(int h) {\n shape_height = h;\n }\n int perimeterOfSquare(int s) {\n return 4 * s;\n }\n int perimeterOfRectange(int l, int b) {\n return 2 * (l + b);\n }\n \n protected:\n int shape_width;\n int shape_height;\n};\n```\nThis will work, but OOP suggests that we should try to stay close to real-world logic. So, we can make a class Shape as a parent class and then make separate classes like Square and Rectangle as child classes. This will make the code easier to maintain, and if you plan to add anything new in the future, then you can add that in the child class. To implement this feature, we need to use Abstract Classes. Abstract classes in C++ need at least one **pure virtual function** in a class. The classes that inherit the abstract class must define the pure virtual function; otherwise, the subclass will become an abstract class.\n\n:::\n\n:::section{.main}\n## Restrictions on Abstract Classes\nThere are some restrictions on abstract classes in C++.\n\nAbstract classes cannot be used for the following –\n\n* Variables or member data\n* Argument types\n* Function return types\n* Types of explicit conversions.\n\nThe constructors of the abstract class in c++ can call other member functions, but if they directly or indirectly call the pure virtual function, then the result is undefined.\n\nBut wait! What is a pure virtual function anyway?\n\nTo understand the **pure virtual function**, first, let’s understand virtual functions.\n\nA [**virtual function in C++**](https://www.scaler.com/topics/virtual-function-in-cpp/) is a member function declared within a base class and redefined by the derived class.\n\nA **pure virtual function (or abstract function)** is a virtual function with no definition/logic. It is declared by assigning 0 at the time of declaration.\n\nLet’s take a look at an example that will make things clear.\n\n```cpp\n#include\u003ciostream\u003e\nusing namespace std;\n\n// Shape class.\nclass Shape {\n public:\n \n // Function to calculate the parameter, declared as pure virtual, so all the derived classes necessarily need to implement this.\n virtual int perimeter() = 0;\n void width(int w) {\n shape_width = w;\n }\n void height(int h) {\n shape_height = h;\n }\n \n protected:\n int shape_width;\n int shape_height;\n};\n\nclass Rectangle: public Shape {\n public: \n // Class Rectangle provided implementation of perimeter() function.\n int perimeter() {\n return (2 * (shape_width + shape_height));\n }\n};\n\nclass Square: public Shape {\n public: \n // Class Square provided implementation of perimeter() function.\n int perimeter() {\n return (4 * shape_width);\n }\n};\n\nint main() {\n Rectangle R;\n Square S;\n\n R.width(10);\n R.height(5);\n S.width(10);\n\n cout \u003c\u003c \"Perimeter of Rectangle: \" \u003c\u003c R.perimeter() \u003c\u003c endl;\n cout \u003c\u003c \"Perimeter of Square: \" \u003c\u003c S.perimeter() \u003c\u003c endl;\n return 0;\n}\n```\n**Output –** \n```plaintext\nPerimeter of Rectangle : 30\nPerimeter of Square: 40\n```\nIn the above code, you can see that the function `perimeter()` is a pure virtual function, the **“virtual”** keyword is used, and it is assigned a value of 0.\n\nIn the derived classes, **Rectangle** and **Shape** redefine the pure virtual function.\n\n:::\n\n:::section{.main}\n## Characteristics of Abstract Class in C++\n1. Abstract Classes must have at least one pure virtual function.\n\n```cpp\nvirtual int perimeter() = 0;\n```\n2. Abstract Classes cannot be instantiated, but pointers and references of Abstract Class types can be created. You cannot create an object of an abstract class.\nHere is an example of a pointer to an abstract class.\n\n```cpp\n#include\u003ciostream\u003e\nusing namespace std;\n\nclass Base {\n public:\n virtual void print() = 0;\n};\n\nclass Derived: public Base {\n public: \n void print() {\n cout \u003c\u003c \"This is from the derived class \\n\";\n }\n};\n\nint main(void) {\n Base* basePointer = new Derived();\n basePointer -\u003e print();\n return 0;\n}\n```\n**Output –** \n```plaintext\nThis is from the derived class\n```\n3. Abstract Classes are mainly used for **Upcasting**, which means its derived classes can use its interface.\n4. Classes that inherit the Abstract Class must implement all pure virtual functions. If they do not, those classes will also be treated as abstract classes.\n\n:::\n\n:::section{.main}\n## Why Can’t We Make an Abstract Class Object?\nAbstract classes in C++ cannot be instantiated because they are “abstract”. It’s like someone is telling you to draw an animal without telling you which specific animal. You can only draw if the person asks you to draw a cat, dog, etc., but an animal is abstract.\n\nThe same is the case with abstract classes in C++, so we can’t create objects, but we can create a pointer of an abstract class.\n\n:::\n\n:::section{.summary}\n## Conclusion\nThrough this article, you now know:\n\n* What is Abstract Class in C++?\n* What is Inheritance?\n* What is Abstraction?\n* How to create and work with Abstract Class in C++?\n* What are virtual functions, and what is the difference between virtual and pure virtual functions?\n\nThat’s all for now, folks! \n\nThanks for reading. \n\n\n:::\n","mediaList":[],"pageClass":"articlePage","rootClass":"articleLayout","subProduct":"article","fallback":{"https://www.scaler.com/topics/api/v1/search/courses/1/6/":[{"slug":"python-for-beginners","title":"Python Course for Beginners With Certification: Mastering the Essentials","category_type":"topics_course","cover_image_thumbnail":"https://www.scaler.com/topics/images/course_card_image_pybeg.webp","featured_image":"https://www.scaler.com/topics/images/course_featured_image_pybeg.webp","modules_count":16,"description":"Welcome to the free Python course with certificate for beginners, designed to help you kickstart your programming journey. This comprehensive Python course online offers a certificate upon completion, covering essential topics like basic Python fundamentals, data structures, object-oriented programming, and more. With 9 hours and 48 minutes of content, you'll gain the knowledge and confidence to start working on your Python projects.","eligible_for_certificate":true,"instructor_name":"Rahul Janghu","instructor_image":"https://www.scaler.com/topics/images/rahul_janghu.webp","company_image":"https://www.scaler.com/topics/images/Scaler.webp","star_headline":"4.90","headline":"Software Engineer and Instructor at Scaler","app_exclusive":false,"user_registration_count":175844,"is_popular":true,"first_entity":{"type":"Video","uuid":660},"category_meta_url":null,"total_time":"9h 44m","total_entities_count":131,"bookmarked":null,"programs":["data_science","programming_languages"]},{"slug":"java-beginners","title":"Java Course - Mastering the Fundamentals","category_type":"topics_course","cover_image_thumbnail":"https://www.scaler.com/topics/images/Java-master-image.webp","featured_image":"https://www.scaler.com/topics/images/java-master.webp","modules_count":12,"description":"Embark on your programming journey with our Free Java Course with Certificate. Master the fundamentals of Java and gain the skills needed for advanced Java development. This easy-to-follow course is designed with beginners in mind, offering a structured learning path to specialize in Java programming. With no prerequisites, this online Java course empowers you to learn Java at your own pace and take the first step toward a promising career in tech.","eligible_for_certificate":true,"instructor_name":"Tarun Luthra","instructor_image":"https://www.scaler.com/topics/images/instructor-tarun.webp","company_image":"https://www.scaler.com/topics/images/Scaler.webp","star_headline":"5 Star Instructor on Scaler","headline":"Software Engineer \u0026 Instructor","app_exclusive":false,"user_registration_count":143336,"is_popular":true,"first_entity":{"type":"Video","uuid":1},"category_meta_url":null,"total_time":"8h 9m","total_entities_count":95,"bookmarked":null,"programs":["academy","programming_languages"]},{"slug":"javascript-beginners","title":"JavaScript Course With Certification: Unlocking the Power of JavaScript","category_type":"topics_course","cover_image_thumbnail":"https://www.scaler.com/topics/images/Course_Listing_312x136_MrinalBhattacharya","featured_image":"https://www.scaler.com/topics/images/Course_FI_816x352_MrinalBhattacharya.webp","modules_count":9,"description":"Kickstart your journey into web development with this free JavaScript course online with a certificate. Designed for beginners, this comprehensive JavaScript online course covers the essential concepts and skills needed to master Javascript, one of the most popular and widely used programming languages in the world. With a course duration of 10 hours and 9 minutes, you'll learn everything from the basics to advanced techniques, all at your own pace.","eligible_for_certificate":true,"instructor_name":"Mrinal Bhattacharya","instructor_image":"https://www.scaler.com/topics/images/mrinal_bhattacharya.webp","company_image":"https://www.scaler.com/topics/images/Scaler.webp","star_headline":"4.8","headline":null,"app_exclusive":false,"user_registration_count":78003,"is_popular":true,"first_entity":{"type":"Video","uuid":1637},"category_meta_url":null,"total_time":"10h 14m","total_entities_count":78,"bookmarked":null,"programs":["academy","programming_languages","frontend_development"]},{"slug":"dbms","title":"DBMS Course - Master the Fundamentals and Advanced Concepts","category_type":"topics_course","cover_image_thumbnail":"https://www.scaler.com/topics/images/course_card_image_dbms.webp","featured_image":"https://www.scaler.com/topics/images/course_featured_image_dbms.webp","modules_count":16,"description":"Scaler Topics free DBMS course is designed to help beginners learn about the fundamental concepts of database management systems. The course is completely online, and it comes with a free certificate of completion that you can add to your resume or LinkedIn profile. You'll learn about the most popular DBMS like MySQL, Oracle, and SQL Server, as well as the theoretical foundations of databases.","eligible_for_certificate":true,"instructor_name":"Srikanth Varma","instructor_image":"https://www.scaler.com/topics/images/srikant-varma_instructor.webp","company_image":"https://www.scaler.com/topics/images/Scaler.webp","star_headline":"5","headline":"Lead DSML Instructor at Scaler","app_exclusive":false,"user_registration_count":74784,"is_popular":false,"first_entity":{"type":"Video","uuid":1620},"category_meta_url":null,"total_time":"1d 5h 17m","total_entities_count":90,"bookmarked":null,"programs":["academy"]},{"slug":"cpp-beginners","title":"C++ Course: Learn the Essentials","category_type":"topics_course","cover_image_thumbnail":"https://www.scaler.com/topics/images/cpp_card_master.webp","featured_image":"https://www.scaler.com/topics/images/cpp-master.webp","modules_count":14,"description":"Gain programming expertise with our C++ Course! Covering basics to advanced concepts, this online program provides a comprehensive curriculum encompassing environment setup, variables, conditional statements, loops, functions, pointers, arrays, sorting, character arrays, strings, and more. This C++ online course is perfect for beginners or seasoned programmers looking to enhance their skills and earn a certificate.","eligible_for_certificate":true,"instructor_name":"Prateek Narang","instructor_image":"https://www.scaler.com/topics/images/instructor-prateek.webp","company_image":"https://www.scaler.com/topics/images/Scaler.webp","star_headline":"5 Star Instructor on Udemy","headline":"Instructor \u0026 Engineering Lead","app_exclusive":false,"user_registration_count":66813,"is_popular":false,"first_entity":{"type":"Video","uuid":89},"category_meta_url":null,"total_time":"9h 24m","total_entities_count":105,"bookmarked":null,"programs":["academy","programming_languages"]},{"slug":"python-sql-data-science","title":"Python and SQL for Data Science","category_type":"topics_course","cover_image_thumbnail":"https://www.scaler.com/topics/images/course_card_image_pds.webp","featured_image":"https://www.scaler.com/topics/images/course_featured_image_pds.webp","modules_count":8,"description":"Introducing the Free Data Science with Python and SQL Certification Course Online, a comprehensive beginner's program designed to help aspiring data scientists learn the essential skills in the rapidly growing field of data science. This course offers a unique blend of practical and theoretical knowledge, combining the powerful programming language Python and the versatile database management system SQL to help you analyze, visualize, and interpret data efficiently.\n","eligible_for_certificate":true,"instructor_name":"Srikanth Varma","instructor_image":"https://www.scaler.com/topics/images/srikant-varma_instructor.webp","company_image":"https://www.scaler.com/topics/images/Scaler.webp","star_headline":"5","headline":"Lead DSML Instructor at Scaler","app_exclusive":false,"user_registration_count":61626,"is_popular":false,"first_entity":{"type":"Video","uuid":1624},"category_meta_url":null,"total_time":"14h 46m","total_entities_count":73,"bookmarked":null,"programs":["data_science"]}],"/course/cpp-beginners":[{"slug":"cpp-beginners","title":"C++ Course: Learn the Essentials","cover_image_thumbnail":"https://www.scaler.com/topics/images/cpp_card_master.webp","modules_count":14,"eligible_for_certificate":true,"instructors_data":[{"id":1,"name":"Prateek Narang","email":"prateek.narang@scaler.com","headline":"Instructor \u0026 Engineering Lead","courses":"C++, Data Structures, Algorithms","total_scaler_students":"1600+","lectures_delivered":"325","star_headline":"5 Star Instructor on Udemy","total_courses":1,"bio":"Prateek Narang, popular as Prateek Bhaiya is renowned programming instructor and former Google engineer. He has done his B.Tech from Delhi Technological University, and has taught over 100k students in online and offline modes. He is also co-founder of Coding Minutes and his courses are also popular on Udemy. He also leads initiatives at Scaler Topics bringing high quality free content and takes live sessions at Scaler Academy.","company_image":"https://www.scaler.com/topics/images/Scaler.webp","cover_image":"https://www.scaler.com/topics/images/instructor-prateek.webp","app_cover_image":null}],"app_exclusive":false,"user_registration_count":0}],"https://www.scaler.com/topics/api/v1/recommendations/Article/abstract-class-in-cpp/6/cpp":[{"id":"257","type":"basic_article","attributes":{"title":"Inheritance in C++","slug":"inheritance-in-cpp","published_at":"2021-12-09T00:00:00.000Z","last_updated_at":"2024-01-05T07:57:29.000Z","read_time":null}},{"id":"264","type":"basic_article","attributes":{"title":"Polymorphism in C++","slug":"polymorphism-in-cpp","published_at":"2022-07-01T00:00:00.000Z","last_updated_at":"2024-04-13T00:59:14.000Z","read_time":null}},{"id":"530","type":"basic_article","attributes":{"title":"Abstract Class in Java","slug":"abstract-class-in-java","published_at":"2022-02-04T00:00:00.000Z","last_updated_at":"2024-07-11T16:56:57.000Z","read_time":null}},{"id":"690","type":"basic_article","attributes":{"title":"Abstraction in C++","slug":"abstraction-in-cpp","published_at":"2022-06-10T00:00:00.000Z","last_updated_at":"2024-06-15T16:14:00.000Z","read_time":null}},{"id":"1946","type":"basic_article","attributes":{"title":"Classes and Objects in C++","slug":"class-and-object-in-cpp","published_at":"2022-09-15T00:00:00.000Z","last_updated_at":"2024-06-23T12:22:26.000Z","read_time":null}},{"id":"2238","type":"basic_article","attributes":{"title":"Nested Classes in C++","slug":"nested-class-in-cpp","published_at":"2022-10-12T00:00:00.000Z","last_updated_at":"2023-10-16T00:00:00.000Z","read_time":null}}]}},"__N_SSG":true},"page":"/[...slug]","query":{"slug":["cpp","abstract-class-in-cpp"]},"buildId":"6jK709HyxmpV6buc4IRmo","assetPrefix":"https://d1g0iq4cbcvjcd.cloudfront.net/topics","runtimeConfig":{"assetPrefix":"https://d1g0iq4cbcvjcd.cloudfront.net/topics","basePath":"/topics"},"isFallback":false,"dynamicIds":[65177,33161,43766,41631,96770,69605],"gsp":true,"scriptLoader":[]}</script></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10