Maybe faulty use of inheritance / composistion?

  • Thread starter Thread starter Flare
  • Start date Start date
F

Flare

Hi I have this..


class BaseUnit;
....
class ResizeBorder : Shape
....

class Shape : BaseUnit
{
ResizeBorder a = new ResizeBorder();
}

(The classes offcourse has implementations)

When i do this i get a stackOverFlowException.

If ResizeBorder dosent inherit from shape it works perfeckt...Am I doing
somethíng wrong? Or is the StackOverFlow maybe caused ba something else wich
first shows when i use the above form?

Anders
 
a shape has a resize border (you allocate one in the constructor)
a resize border is a shape (by inheritance)
so a resize border has a resize border
the resize border of a resize border is a shape
so the resize border of a resize border has a resize border
...
Bruno.
 
Back
Top