Item 1-point-circle-cylinder Group Design (1)

Source: Internet
Author: User

Questions and codes:

/* *copyright (c) 2016, Yantai University School of computer *all rights reserved. * File name: Zwj.cpp *:    Zhang Weijing * Completion Date: May 4, 2016 * version number: v1.0 * * Problem Description: Follow the prompts, starting from the base class gradually complete the point--circle--cylinder class family design. * Input Description: * Program output: */#include <iostream>using namespace Std;class point{public: Point    (Double a=0,double b=0);    void Show_point ();    Double Getx () {return x;}    Double Gety () {return y;} Protected:    double X;    Double y;}; Point::P oint (double a,double b) {    x=a;    Y=b;} The coordinates of void Point::show_point () {    cout<< "point are:" <<x<< "," <<Y<<ENDL;} int main () {point    P1;    P1.show_point ();    return 0;}



Operation Result:



Summary of Knowledge points:

Derived class constructor: the constructor for the ① base class is not inherited, and its constructor is declared in the derived class. When you define a constructor, you only need to initialize the new members of the class, initialize the inherited base class members, or automatically call the base class constructor to complete the ②. ③ to ensure that the constructors required by the derived class are defined in the base class.

Learning experience:

Item 1-point-circle-cylinder Group Design (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.