uses classes calculate cylinder volume and surface area issues.

hey guys, I'm new to programming. I am trying to calculate the volume and the surface area of a cylinder using classes in C++. I keep getting two errors saying that 'class Cylinder' has no member named 'surface_area' and 'class Cylinder' has no member named 'write'. I know this is probably a trivial issues for most people in programing. However, I am at a loss for what I need to change. any input would be greatly appreciated.

**this is my main ()**

#include <iostream>
#include <iomanip>

#include "cylinder.h"
using namespace std;

int main()
{
double radius, height, base, width;

cout << fixed << showpoint << setprecision(2);

cout << "Enter cylinder height and radius >>> ";
cin >> height >> radius;
Cylinder one (radius, height);
cout << "The cylinder volume is " << one.volume () << endl;
cout << "The cylinder surface area is " << one.surface_area () << endl;
one.write(cout);

return 0;
}

**this is the header file**

using namespace std;
class Cylinder
{
public:
// Constructors
Cylinder();
Cylinder(double r, double h);
// Accessors
double getRadius();
double getHeight();
void setRadius(double r);
void setHeight(double h);
double area();
double volume();
private:
double radius;
double height;
};


**this last .cpp contains the constructors and caculations**

#include "cylinder.h"
const double PI = 3.14159;
// Constructors
Cylinder::Cylinder()
{
radius = 0;
height = 0;
}
Cylinder::Cylinder(double r, double h)
{
radius = r;
height = h;
}
// Accessors
double Cylinder::getRadius()
{
return radius;
}
double Cylinder::getHeight()
{
return height;
}
// Setters
void Cylinder::setRadius(double r)
{
radius = r;
}
void Cylinder::setHeight(double h)
{
height = h;
}
// Calculations
double Cylinder::area()
{
return 2 * PI * radius * radius + 2 * PI * radius * height;
}
double Cylinder::volume()
{
return PI * radius * radius * height;
}
I was able to figure out the error about the 'class Cylinder' has no member named 'surface_area'... i forgot to put surface_ in my declaration.

Though, I am still at a loss for the second error, 'class Cylinder' has no member named 'write'.
Topic archived. No new replies allowed.