# Thread: Deriving one class from another

1. ## 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"

cout << "\nEnter radius of circle: ";
cout << "Enter center point of circle:";
}
float Circle :: area() const {
const float pii = 3.14159;
}
void Circle :: I_am() const {
cout << "\nI am Circle ";
}```
Circle.h
Code:
```#ifndef _circle
#define _cicle
#include "point.h"
class Circle : public Point{
private:
public:
float area() const;
virtual void I_am(void) const;
};
#endif```
point.cpp
Code:
```#include <iostream.h>
#include <math.h>
#include "point.h"

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 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 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

2. Get rid of the ".h". Chances are your compiler is newer than that old style of doing things.
Code:
`#include <iostream>`
Quzah.

3. and on the math header too
Code:
`#include<cmath>`

Correct me if i'm wrong because i'm not 100% sure of this.

5. From 17.4.3.1.2
- Each name that contains a double underscore (__) or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use.

Technically, _point is ok.