# Deriving one class from another

• 02-07-2005
SpudNuts
Deriving one class from another
Ok, yeah, it's homework. Here's the deal, I need to make a class "point", perform operations on the point, like showing the point, setting and printing coordinates, and showing x and y coordinates, then... design a class "circle" that can sotre radius and center and derive "circle" from "point" to perform operations on a circle, like setting radius, printing the radius, calculating and printing the area and circumference and such.

Here is what I've done so far:

circle.cpp
Code:

```#include <iostream.h> #include <math.h> #include "Circle.h" void Circle :: read() {     cout << "\nEnter radius of circle: ";     cin >> radius;     cout << "Enter center point of circle:";     Point::read(); } float Circle :: area() const {     const float pii = 3.14159;     return  pii * radius * radius; } void Circle :: I_am() const {     cout << "\nI am Circle "; }```
Circle.h
Code:

```#ifndef _circle #define _cicle #include "point.h" class Circle : public Point{     private:         float radius;   public:         void read();         float area() const;         virtual void I_am(void) const; }; #endif```
point.cpp
Code:

```#include <iostream.h> #include <math.h> #include "point.h" void Point::read() {     cout << "\n Enter x-coordinate of point: ";     cin >> x;     cout << " Enter y-coordinate of point: ";     cin >> y; } float Point :: area() const{     return 0.0; } void Point :: I_am() const {     cout << "\nI am Point "; } float Point::distance(const Point &p2)const{     return sqrt( (p2.x-x)*(p2.x-x) + (p2.y - y)*(p2.y - y)); }```
point.h
Code:

```#ifndef _point #define _point #include "shape.h" class Point : public Shape {     public:       virtual void read();       virtual float area() const;       virtual float distance(const Point &p2)const;       virtual void I_am() const;     private:       float x;       float y; }; #endif```
Then I wrote an abstract

shape.h
Code:

```#ifndef _shape #define _shape class Shape {     public:         virtual void read() = 0;         virtual float area()const = 0 ;       virtual void I_am() const = 0; }; #endif```
Now, i'm getting an error:

point.pp
Cannot open include file: 'iostream.h': No such file or directory
circle.cpp
Cannot open include file: 'iostream.h': No such file or directory

Any help is appreciated.
Thanks
• 02-07-2005
quzah
Get rid of the ".h". Chances are your compiler is newer than that old style of doing things.
Code:

`#include <iostream>`
Quzah.
• 02-08-2005
major_small
and on the math header too
Code:

`#include<cmath>`
• 02-08-2005
Brain Cell