Classes

This is a discussion on Classes within the C++ Programming forums, part of the General Programming Boards category; Hi, I am new to programming and I need anyone's help on this. "Creat a class Rectangle. The class attributes ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    10

    Post Classes

    Hi, I am new to programming and I need anyone's help on this.
    "Creat a class Rectangle. The class attributes length and width, each of which default to 1. It has member functions that calculate the perimeter and the area of the rectangle. It has set and get functions for both length and width. The set functions should verify that length and width are each floating point numbers larger than 0.0 and less than 72.12.

    Here's what I have so far, and can't go beyond this:
    #include <iostream.h>
    class Rectangle // Class Rectangle
    {
    public:
    Rectangle(float=1, float=1); // Constructor
    double perimeter(float, float); // Perimeter function
    double area(float, float); // Area funcion
    void set(float, float);
    void get(float, float);
    private:
    float length;
    float width;
    }; // End of class Rectangle

    Rectangle::Rectangle(float L, float W) // Scope function
    {



    }
    double Rectangle:erimeter(float L, float W, float H)
    {



    }
    double Rectangle::area(float L, float W, float H)
    {


    }
    void Rectangle::set(float L, float W)
    {
    length =

    }
    void Rectangle::get(float L, float W)
    {



    }
    int main() // main()
    {


    return 0;
    } // End of main()

    Thanks

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Okay, so what do you need help with? Would you like someone to write all the code for you?

  3. #3
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Do you know how to work with classes?
    if yes... Then you should be able to write that class because it's a very simple, and straight forward example.
    if not... I suggest you read some tutorials about classes or read your book if you have one, then post any questions you have here.
    none...

  4. #4
    stovellp
    Guest
    1: You have your perimiter and area functions taking 3 arguments when their class declarations says they take 2.

    2: All you have to do now is put in the formula to calculate the area and perimiter, and make sure in the Set... functions that the number bieng set is greater than 0.0 and less than 72. whatever.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 10:47 AM
  2. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 08:04 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 04:38 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21