Ok. I have a start on the program based off of the tutorial linked by MadCow257. However, when I compile, it gives me errors. Heres the code so far:
I get the following errors:
// dynamic allocation and polymorphism
using namespace std;
int width, height, length;
void set_values (int a, int b, int c)
width=a; height=b, length=c;
virtual int area (void) =0;
void printarea (void)
cout << this->area() << endl;
virtual int volume(void) =0;
cout << this->volume() << endl;
class TwoDimensionalShape: public Shape
return (width * height);
class ThreeDimensionalShape: public Shape
return (width * height * length);
Shape *ppoly1 = new TwoDimensionalShape;
Shape *ppoly2 = new ThreeDimensionalShape;
And there are a few more warnings and errors that are basically the same, and they point to the various Class and Function definitions.
error C2259: 'TwoDimensionalShape' : cannot instantiate abstract class due to following members:
see declaration of 'TwoDimensionalShape'
warning C4259: 'int __thiscall Shape::volume(void)' : pure virtual function was not defined
As to why im 'tutoring' when I don't have a full grasp of the material myself... Well, tutoring was the wrong word. Its more I show them how to do things as I figure them out myself, and help them do assignments(Note: I don't do assignments for others, I just show them how to get started). I enjoy doing this stuff, and these excersices are good practice.