当前位置:网站首页>Week 10 - task 3- from point to circle to cylinder
Week 10 - task 3- from point to circle to cylinder
2022-06-29 05:46:00 【sxhelijian】
【 subject 】
(1) Create a Point( spot ) class , Contains data members x,y( Coordinates );
(2) With Point Base class , Derive a Circle( round ) class , Add data members ( radius );
(3) And then to Circle Class is the direct base class , Derive a Cylinder( Cylinder ) class , Add more data members ( high ).
Require programming , Design all kinds of basic member functions ( Include constructors 、 Destructor 、 Modify the common interface of data members and get data members 、 Overloaded operators for output “<<” Functions, etc ), It can be used to deal with the above objects , Finally, the surface area of the cylinder is obtained 、 Volume and output .
( Tips : This task can be divided into three sub tasks, which are divided into several steps . The first class of the first class , Then declare the derived class , Step by step , Step by step debugging .—— This method can be applied to any project )
【 analysis 】 The key is to understand the inheritance of each class and the relationship between different kinds of geometry . To describe a circle , The center and radius of the circle need to be pointed out , The center of the circle is a point . When we use Point Base class , Derive a Circle( round ) Class time ( Page 2 Requirements ), Data members from the base class ( The description of the point ) As a description of the center of a circle , Just add data members describing radius . Same thing , With Circle Class is the direct base class , Derive a Cylinder( Cylinder ) Class time ( The second part of this topic is 3 Requirements ), The circle described by the base class is the circular section of a cylinder , Only increase “ high ” Attribute is enough .
The following answer is in three steps , Seriously experience this idea of solving problems . When you are faced with a problem where you need to define multiple classes , Do it one by one , Test as you go . On the basis of rigorous analysis , When there is an inheritance relationship between classes , First implement the base class , Then implement the derived class .
【 Refer to the answer 】
One 、 To implement the base class Point Class and for testing main() function
Two 、 Implement derived classes Circle And its test functions
3、 ... and 、 Realization Circle The derived class Cylinder And test functions
边栏推荐
- The win11 file resource manager has an explicit Caton, and Microsoft promises to improve the performance in 2022
- Software architecture final review summary
- Conditional test, if and case conditional test statements of shell script
- Regular expressions for shell script values
- 开启生态新姿势 | 使用 WordPress 远程附件存储到 COS
- ASP. Net core 6 framework unveiling example demonstration [03]:dapr initial experience
- real time AI based system questionaires
- Sailing with karmada: multi cluster management of massive nodes
- 2-nitro-5,10,15,20-tetra (4-methylphenyl) porphyrin copper (no2tmpp) Cu) /2-nitro-5,10,15,20-tetra (4-methylphenyl) porphyrin (no2tmpp) H2) Qiyue porphyrin supply
- Blip: conduct multimodal pre training with cleaner and more diverse data, and the performance exceeds clip! Open source code
猜你喜欢

Cipher

The fresh student who was born in Ali after 2000: it's really fragrant to mend this

Research Report on the recommended lithography industry in 2022 industry development prospect market investment analysis (the attachment is a link to the network disk, and the report is continuously u

Alibaba microservice component Sentinel

HTTP Caching Protocol practice
![[high concurrency] deeply analyze the callable interface](/img/dc/174f97fdd27180ed210d76768cc345.jpg)
[high concurrency] deeply analyze the callable interface
![[chromium] win10 vs2019 environment chromium configuration and compilation.](/img/20/428e6b22ed6955a732dd14d5ff0e3d.jpg)
[chromium] win10 vs2019 environment chromium configuration and compilation.

2022 recommended trend toy blind box industry research report industry development prospect market analysis white paper (the attachment is a link to the network disk, and the report is continuously up

Conditional test, if and case conditional test statements of shell script

5000+ word interpretation | Product Manager: how to do a good job in component selection?
随机推荐
Output various graphics and text on the console through C #
Use of sed in shell script
How to insert pseudo code into word documents simply and quickly?
Analysis report on the investment market of the development planning prospect of the recommended rare earth industry research industry in 2022 (the attachment is a link to the online disk, and the rep
Review of MySQL knowledge points
AttributeError: module ‘torch. nn. Parameter 'has no attribute' uninitializedparameter 'solution
Software architecture final review summary
Plugin
Robot reinforcement learning - transferring end-to-end videomotor control from simulation to realworld (curl 2017)
Cloud native annual technology inventory is released! Ride the wind and waves at the right time
The win11 file resource manager has an explicit Caton, and Microsoft promises to improve the performance in 2022
證券開戶安全麼,有沒有什麼危險呢
C語言用 printf 打印 《愛心》《火星撞地球》等,不斷更新
Use typescript compiler parameter 'skiplibcheck' - usage of the typescript compiler argument'skiplibcheck'
20 years Qinhuangdao D - exam results (dichotomy + thinking, with error prone data)
Blip: conduct multimodal pre training with cleaner and more diverse data, and the performance exceeds clip! Open source code
Ctrip launched the "3+2" office mode. Are you sour?
Why Houdini made the pyside2 plug-in crash
I haven't encountered these three problems. I'm sorry to say that I used redis
β- Tetraphenyl nickel porphyrin with all chlorine substitution| β- Thiocyano tetraphenyl porphyrin copper| β- Dihydroxy tetraphenyl porphyrin 𞓜 2-nitroporphyrin | supplied by Qiyue