Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use pure virtual functions and abstract classes in C++

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What this article shares with you is about how to use the pure virtual functions and abstract classes in C++. The editor thinks it is very practical, so I hope you can learn something after reading this article. Let's take a look at it with the editor.

/ * Pure virtual functions and abstract classes-Why not 2014/01/05*/#include#includeusing namespace std;const double pi=3.14159;class Shape {public: virtual void show (void) = 0; virtual double area (void) = 0; class triangle:public Shape {public: triangle (double=0,double=0,double=0); void show (void); double area (void); private: double a dagger bjort c;}; class rectangle: public Shape {public: rectangle (double=0,double=0) Void show (void); double area (void); private: double width,length;}; class circle: public Shape {public: circle (double = 0); void show (void); double area (void); private: double r;}; triangle::triangle

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report