Hi, I'm workin on using a header file with 2 .cpp files to find the volume of a cylinder. Heres what I have for the header file.
the name for the header file is cylinder.cppCode:class cylinder { private: double r,l,v; public: double cylvol(); cylinder(); void get_data(); };
::this is cylinder.cpp::
and last but not least the main program called foo.cppCode:#include "cylinder.h" #include <iostream> using namespace std; void cylinder::get_data() { cout << "Please enter the radius and length of the Cylinder" << endl; cin >> r >> l; return; }; double cylinder::cylvol() { const double PI = 3.14157; v=PI*r*r*l; return v; }; cylinder::cylinder() { r = 0.0; l = 0.0; v = 0.0; };
I get 3 link errors, please tell me what I'm doing wrongCode:#include "cylinder.cpp" int main() { cylinder junk; junk.get_data(); cout << "The volume of the cylinder is: " << junk.cylvol() << endl; return 0; };



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.