Thread: 2 errors in my code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #12
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I have a few comments!

    - The Rectangle class needs a destructor, since you wrote a constructor.
    - You should use your getter functions to compose the equation in your area function.
    - The Cube class inherits the height variable, you dont need to make another private member for the Cube class. The Cube class can also simply use Rectangle's implementation, since nothing is different about it. Save yourself the typing.

    Most importantly, default parameters belong in the implementation of the constructor:
    Code:
    Rectangle::Rectangle(double l=0., double w=0.) : length(l), width(w) 
    { }
    And of course the loop will be endless until the user types something that isn't 1 or 2. Type 0, for instance, and the loop breaks.
    Last edited by whiteflags; 05-03-2006 at 11:02 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  2. << !! Posting Code? Read this First !! >>
    By kermi3 in forum Linux Programming
    Replies: 0
    Last Post: 10-14-2002, 01:30 PM
  3. RAM/Swap Memory Code Errors
    By ghe1 in forum Linux Programming
    Replies: 2
    Last Post: 04-01-2002, 07:37 AM
  4. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 12:51 PM