What is wrong to use base class object to initialize the member variables and then using the values by accessing them via derived class objects?
I am trying following code
Because poly != rect ... when you declare rect it has uninitialized new polygon.. you need to set the values of "rect" .
Why can't I initialize member variables using a object of base class?
The concept is that rectangle is not a polygon .. rectangle has a polygon ... although in math what i said won't make any sense. because rectangle is a polygon. Using inheritance you have to keep in mind that derived class has a base class.