The idea of a function is that you pass in values that you want the function to operate on. If length, width and depth are always going to be initialised to 10,20 and 30 then you don't need to pass anything into Box(). But if you want to set length to l etc, then you need to do length=l; instead of length=20.0;, and when you call Box, give it those values, e.g. Box(10,20,30).

I suggest you get the Rectangle class working first, then you can start work on Box. Take it a step at a time. "Rectangle::Rectangle(double = 1.0,double = 1.0);" - hmm, you seem to be taking "initialize: double=1.0 and double=1.0" rather too literally. The Rectangle constructor should take no parameters if you're always going to be using fixed values, or it should take two named parameters (e.g. Rectangle(double l,double w), then you can assign those values to length and width, i.e. length=1.0 if you're using fixed values, or length=l if you're using parameters.

In a way it's similar to maths; if a function is not dependent on specific variables then it's pointless passing them in. If f() is dependent on x but not y, then you would define f(x) rather than f(x,y); you could set f(x,y)=x^2, but then everyone would ask "why y?".

Correct results don't always mean the code is correct. Does the code give the correct results for different size boxes and rectangles?

You haven't specified the Rectangle::Rectangle function body anywhere, just a prototype. I'm not sure why the code works at all; Rectangle::length and Rectangle::width haven't been initialised anywhere. What compiler are you using?