This is my first post and I'm sort of new to programming and figured joining this forum to try and get some help. So please excuse me if I happen to miss something.
Task:
- Create a cylinder specified by my program with the radius and height
- Which will calculate the surface area and volume of the cylinder
Issue:
- I'm creating a cylinder program that isn't compiling correctly.
- Yes this is for a college course I'm not asking for the answer but just if anyone can help me figure out what I'm doing wrong...
Error:
- Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Utilizing:
- Mac OSX 10.6
- Compiling in Terminal
***Main***
#include <iostream>
#include "cylinder.h"
using namespace std;
int main()
{
Cylinder CylinderOne(10.0, 10.0);
cout << "Cylinder 1 Radius: " << CylinderOne.getRadius() << endl;
cout << "Cylinder 1 Height: " << CylinderOne.getHeight() << endl;
cin.get();
return 0;
}
***Class***
#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 volume() * 2 * PI * radius * radius;
}
double Cylinder::volume()
{
return PI * radius * radius * height;
}
***Header***
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;
};