-
Help with program?
Hi all,
i was wondering if anyone could please help me out as i'm am struggling with programming. Our Lecturer has given us this assignment and i need help getting started. I'm asking on here because our lecturer isn't very helpful and doesn't explain things very well. (By the way i'm am a real novice at programming)
The start of the assignement is as follows:
Create a base class named ‘Quadrilateral’ that contains 4 float attributes (with a ‘protected’ access specifier) called side1, side2, side3, side4. The member functions (methods) must consist only of the following:
1. a four-argument constructor with default values of 1.0 for all attributes
2. a function area( ) to return a float value of ‘-1’ since the area is indeterminate.
3. a function perimeter( ) to return a float value, the sum of all four attributes.
4. a function getSide1( ) to return side1.
5. a function name( ) to return a char pointer (char*) initialized to “Quadrilateral”.
6. a destructor function.
Create a derived class named ‘Rectangle’ with public inheritance from Quadrilateral. The member functions (methods) must consist only of the following:
1. a two-argument constructor with default values of 1.0. The first argument is assigned to ‘side1’ and ‘side3’, the second argument is assigned to ‘side2’ and ‘side4’.
2. a function area( ) to return a type float from the product of size1 and size2.
3. a function name( ) to return a char pointer (char*) initialized to “Rectangle”.
4. a destructor function.
If any could please help i would really appreciate it
Thanks for your time
Mark.
-
Give it a try on your own. We are here to guide and help you, not think for you. Show some effort and we'll be glad to help you.
-
One of your countrymen wrote a very good book on C++. It's called Ivor Horton's Beginning C++. Read the chapter on classes and the chapter on inheritance, and you'll be able to do that program in a snap. Good luck.
-
what i've done so far
this is what i've done so far, could anyone please tell me if i'm on the right lines?
Cheers Mark.
Code:
// Mark Gaskell
// Module: Prog1B LCT 1006
// Filename: Part1
#include <iostream.h>
int main()
class Quadrilateral
{
protected:
// Constructor definition
Quadrilateral(float side1, float side2, float side3, float side4)
public:
char* name();
float getSide1();
float perimeter();
float area();
~Quadrilateral();
}
float Quadrilateral::area()
{
}
float Quadrilateral::perimeter()
{
}
float Quadrilateral::getSide1()
{
}
char* Quadrilateral::name()
{
}
-
Boy, thats a big favor you r asking for buddy!
I have something that might help u.
( U r very lucky I'm in a good mood right now,or else I would have copied and pasted RoD's reply )
-
Thanks a lot
Just sayin thanks a lot for that mate, you've been a great help
I just needed something to get me on way that's all
Cheers Mark