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
Circle.hCode:#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 "; }
point.cppCode:#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.hCode:#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)); }
Then I wrote an abstractCode:#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
shape.h
Now, i'm getting an error:Code:#ifndef _shape #define _shape class Shape { public: virtual void read() = 0; virtual float area()const = 0 ; virtual void I_am() const = 0; }; #endif
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



LinkBack URL
About LinkBacks


