Ok, I removed all of the "statics" and I removed the =0 from the default constructors.
And it is still returning zero when I call the getX and getY functions, but only when they're called from the derived class. When they're called from within the base class they return the correct information.
I'm going to apologize in advance if this is too much, but I am going to post all of my code. I'm getting desperate.
Main .cpp
Code:
#include "pointType.h"
#include "circleType.h"
#include "cylinderType.h"
#include <iostream>
using namespace std;
int main()
{
pointType point;
double x, y;
cout << "Enter the x-coordinate: ";
cin >> x;
cout << "Enter the y-coordinate: ";
cin >> y;
point.setPoints(x, y);
point.print();
circleType circle;
double r;
cout << "Enter the radius of the circle: ";
cin >> r;
circle.setRadius(r);
circle.print();
cylinderType cylinder;
double h;
cout << "Enter the height of the cylinder: ";
cin >> h;
cylinder.setHeight(h);
cylinder.print();
return 0;
}
base class .h
Code:
#ifndef H_PointType
#define H_PointType
using namespace std;
class pointType
{
public:
void setPoints(double pointX, double pointY);
void print() const;
double getX() const;
double getY() const;
pointType();
pointType(double pointX, double pointY);
private:
double x, y;
};
#endif
base class .cpp
Code:
#include "pointType.h"
#include <iostream>
#include <iomanip>
using namespace std;
void pointType::setPoints(double pointX, double pointY)
{
x = pointX;
y = pointY;
}
void pointType::print() const
{
cout << fixed << setprecision(2) << "The x and y coordinates are: ";
cout << getX() << "," << getY() << "." << endl;
}
double pointType::getX() const
{
return x;
}
double pointType::getY() const
{
return y;
}
pointType::pointType()
{
x;
y;
}
pointType::pointType(double pointX, double pointY)
{
x = pointX;
y = pointY;
}
derived class 1 .h file
Code:
#ifndef H_CircleType
#define H_CircleType
#include "pointType.h"
using namespace std;
class circleType: public pointType
{
public:
void setRadius(double cRadius);
void print() const;
double getRadius() const;
double calcArea() const;
double calcCir() const;
double calcDia() const;
circleType ();
circleType(double cRradius);
private:
double radius;
};
#endif
derived class1 .cpp file
Code:
#include "circleType.h"
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void circleType::setRadius(double cRadius)
{
radius = cRadius;
}
void circleType::print() const
{
cout << "The radius of the circle is: " << getRadius() << endl;
cout << "The diameter of the circle is: " << calcDia() << endl;
cout << "The area of the circle is: " << calcArea() << endl;
cout << "The circumference of the circle is: " << calcCir() << endl;
cout << fixed << setprecision(2) << "The x and y coordinates are: ";
cout << getX() << "," << getY() << "." << endl;
}
double circleType::getRadius() const
{
return radius;
}
double circleType::calcArea() const
{
double pi = 3.14159;
return (pi * (radius * radius));
}
double circleType::calcCir() const
{
double pi = 3.14159;
return (calcDia() * pi);
}
double circleType::calcDia() const
{
return radius * 2;
}
circleType::circleType() //Default construtor
{
radius;
}
circleType::circleType(double cRadius)
{
radius = cRadius;
}
derived class2 .h file
Code:
#ifndef H_CylinderType
#define H_CylinderType
#include "circleType.h"
using namespace std;
class cylinderType: public circleType
{
public:
void setHeight(double cHeight);
void print() const;
double getHeight() const;
double calcVolume()const;
double calcSurface() const;
cylinderType();
cylinderType(double cHeight);
private:
double height;
};
#endif
derived class2 .cpp file
Code:
#include "cylinderType.h"
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
void cylinderType::setHeight(double cHeight)
{
height = cHeight;
}
void cylinderType::print() const
{
cout << "The height of the cylinder is: " << getHeight() << endl;
cout << "The radius of the cylinder base is: " << getRadius() << endl;
cout << "The volume of the cylinder is: " << calcVolume() << endl;
cout << "The surface area of the cylinder is: " << calcSurface() << endl;
cout << fixed << setprecision(2) << "The x and y coordinates are: ";
cout << getX() << "," << getY() << "." << endl;
}
double cylinderType::getHeight() const
{
return height;
}
double cylinderType::calcVolume() const
{
double pi = 3.14159;
return (height * pi) * (getRadius() * getRadius());
}
double cylinderType::calcSurface() const
{
double pi = 3.14159;
return (2 * calcArea()) + (calcCir() * height);
}
cylinderType::cylinderType()
{
height;
}
cylinderType::cylinderType(double cHeight)
{
height = cHeight;
}