Describe abstract base class. Illustrate an example to explain it.

Go down

Describe abstract base class. Illustrate an example to explain it.

Post by Admin on Tue Feb 17, 2015 11:24 am


A pure virtual function is a function which does not have definition of its own. The classes which derive from this class need to provide definition for such function. A class containing at least one such pure virtual function is called as abstract base class. We can not create objects of abstract class because it contains functions which have no definition. We can create pointers and references to an abstract class.

Consider example of base class Shape and derived classes Circle, Rectangle, triangle etc.
The function Draw() is made pure virtual in the base class Shape. It is overridden by the derived classes. So the class Shape becomes abstract base class.

class Shape
{
int x, y;
public:
virtual void draw() = 0;
};

class Circle: public Shape
{
public:
draw()
{
//Code for drawing a circle
}
};

class Rectangle: public Shape
{
Public:
void draw()
{
//Code for drawing a rectangle
}
};

class Triangle: public Shape
{
Public:
void draw()
{
//Code for drawing a triangle
}
};

Admin
Admin

Posts : 501
Join date : 2015-02-07

View user profile http://seo-expert.editboard.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum
SEO Forum,Dofollow Forum,High PR Forum,startwithclck,Submit a guest post,Best 5 Google Adsense Alternatives for bloggers,Most Common Advantages & Disadvantages of Guest Blogging,Apply These 12 Secret Techniques To Improve On page Seo Factor,Bluehost Review: Shared Hosting for WordPress,Bluehost Review,Bluehost Reviews,bluehost hosting,godaddy, godaddy hosting, godaddy hosting review,godaddy review, godaddy coupons, godaddy promo code, godaddy coupon, godaddy promo codes, godaddy coupon code, IT Company indiaIT Company SuratIT Company MumbaiIT Company PuneIT CompanyIT Companies indiaIT Companies SuratIT Companies MumbaiIT Companies PuneIT Companies SEO Company indiaSEO Company SuratSEO Company MumbaiSEO Company PuneSEO CompanySEO Companies indiaSEO Companies SuratSEO Companies MumbaiSEO Companies PuneSEO Companies AhmedabadSEO CompaniesDigital Marketing CompanyDigital Marketing Company indiaDigital Marketing Company SuratDigital Marketing Company MumbaiDigital Marketing Company PuneDigital Marketing CompaniesDigital Marketing Companies indiaAffordable Search Engine Optimization Companysearch engine optimisation companiessearch engine optimisation companySeo marketing CompanyIndian SEO CompanyCheap seo companies Best seo companies Seo marketing companiesIndian SEO companiesCheap seo CompanyBest seo CompanyWebsite Optimization CompaniesWebsite Optimization CompanySeo optimization companySeo optimization Companiesdigital marketing agencySeo consultantSeo consultantsSeo consultingSeo consultancySearch engine optimization expertsSeo agencySeo indiaInternet marketing companyTop seo companySeo ServicesAffordable Search Engine Optimization servicesSeo marketing servicesSearch engine optimization and marketingCheap seo serviceBest seo service Cheap seo services Best seo services Digital marketing serviceDigital marketing servicesSeo analysisSeo strategySearch engine optimisation servicesProfessional seo servicesService seoOrganic seo servicesGuaranteed seo servicesMonthly seo servicesServices seoSearch marketing strategyLocal seo servicesLocal seo serviceProfessional seo servicesLocal seo services companySeo company servicesTop local seo companiesTop local seoTop local seo companyLocal seo agencyLocal seo agenciesLocal seo consultantLocal search engine optimisationLocal online marketingLocal search engine marketingSEO trainingSEO training SuratSEO training NavsariSEO training ValsadSEO training AnkleshwarSEO training BharuchInternet Marketing Services Internet Marketing Services SuratInternet Marketing Services NavsariInternet Marketing Services BharuchInternet Marketing Services VadodaraInternet Marketing Services Ankleshwar