0% found this document useful (0 votes)
24 views

#Include #Ifndef POINT - H #Define POINT - H Using Namespace STD Class Point

The document defines classes for geometric shapes like points, circles, and cylinders in C++. It includes the class definitions and constructor/destructor definitions that output information about the shape's properties like coordinates and calculated areas. In the main function, objects of each type are created and their constructors/destructors called to demonstrate the class functionality.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

#Include #Ifndef POINT - H #Define POINT - H Using Namespace STD Class Point

The document defines classes for geometric shapes like points, circles, and cylinders in C++. It includes the class definitions and constructor/destructor definitions that output information about the shape's properties like coordinates and calculated areas. In the main function, objects of each type are created and their constructors/destructors called to demonstrate the class functionality.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <iostream> #ifndef POINT_H #define POINT_H using namespace std; class point { public: point(double = 0.

0, double = 0.0); ~point(); protected: double x; double y; }; #endif point::point(double a, double b) { x = a; y = b; cout << "point constructor: } point::~point() { cout << "point destructor: } #ifndef CIRCLE_H #define CIRCLE_H class circle : public point { public: circle(double r = 0.0, double x = 0.0, double y = 0.0); ~circle(); protected: double radius; double area; }; #endif circle::circle(double r, double a, double b): point(a, b) { radius = r; area = 3.141593 * (radius * radius); cout << "circle constructor: radius is << y << "]" << endl; cout << "area is: " << area << endl; } circle::~circle() { " << radius << "[" << x << "," " << "[" << x << "," << y << "]" << endl;

" << "[" << x << "," << y << "]" << endl;

cout << "circle destructor: radius is << y << "]" << endl; cout << "area is: " << area << endl; } #ifndef CYLINDER_H #define CYLINDER_H

" << radius << "[" << x << ","

class cylinder : public point { public: cylinder(double r = 0.0, double h = 0.0, double x = 0.0, double y = 0.0); ~cylinder(); protected: double radius; double height; double area; }; #endif cylinder::cylinder(double r, double h, double a, double b): point(a, b) { radius = r; height = h; area = 3.141593 * (radius * radius) * height; cout << "cylinder constructor: radius is "," << y << "]" << endl; cout << "height is: " << height << endl; cout << "area is: " << area << endl; } " << radius << "[" << x <<

cylinder::~cylinder() { cout << "cylinder destructor: radius is " << radius << "[" << x << "," << y << "]" << endl; cout << "height is: " << height << endl; cout << "area is: " << area << endl; } int main() { { point p(30.0, 40.5); } cout << endl; circle circle1(6.0, 20.0, 16.5); cout << endl; cylinder cylinder1(12.0, 30.0, 20.0, 40.0); cout << endl; system("pause"); return 0; }

OUTPUT: point constructor: [30,40.5] point destructor: [30,40.5] point constructor: [20,16.5] circle constructor: radius is 6[20,16.5] area is: 113.097 point constructor: [20,40] cylinder constructor: radius is 12[20,40] height is: 30 area is: 13571.7

You might also like