program

Thanks Everyone.
Last edited on
Why exactly does BasicShape have an area member and a getArea function?
Well, Thats what i've been asked to do.
A public member variable - area
public member function - getArea
and calcArea, a pure virtual function.

Theres not much leeway as its an assignment.
Hm, that seems kind of dumb to me...but I guess you are stuck.

Anyway, it seems they want you have calcArea be virtual, and it assigns it's result to the area member variable, which can be accessed through getArea(). FYI, I think you meant private member variable - area.
you got that right buddy.
and, lol, yeah that should be Private member variable - area, what was i thinking!:)
closed account (D80DSL3A)
I think the problem is that you are calling the inherited member function getArea() in your cout statements. This function returns the value of the inherited variable area, which has not been either initialized or calculated. Call calcArea() instead. These virtual functions should return the desired values. Alternately, you could add the calculation of area to the CIRCLE and RECTANGLE class constructors. Then getArea() should return the right values.
Last edited on
Fun2code, Thanks buddy, it works like a charm.
Please don't erase your original message even if it's to "thank everyone". Now the thread is useless to anyone who might have a similar problem in the future.
Topic archived. No new replies allowed.