Marko wrote:
> On Sep 1, 12:38 pm, Neelesh Bodas <neelesh.bo...@gmail.com> wrote:
>> On Sep 1, 3:22 pm, Marko <cb...@outgun.com> wrote:
>>
>> > I have abstract superclass named Element, and several subclasses
>> > derived from it: And, Or, Nand, Nor...
>> > I have method which has to take 2 subclasses of element as its
>> > parameters types.
>> > Can't use void myFunction(Element& e1,Element& e2); prototype because
>> > I am trying to pass it objects of class And or any other subclass.
>> > Need help..
>>
>> Why can't you use void myFunction(Element& e1,Element& e2); ? If
>> 'And', 'Or' etc are publicly derived from Element then 'And' is-an
>> 'Element' and hence it can be passed to a function which exepcts an
>> Element&. What is the exact issue?
>>
>> -N
>
> OK, it just start working.
> I don't know what happened. I probably overlooked something obvious.
>
> But now, I have new problem, and this time I'm not even sure that this
> thing
> can be done the way I am trying to do it.
>
> I have to make a dynamic array of Element type, so it can contain any
> of the derived class objects.
You cannot make an array of that kind. But you can make an array of pointers
to Element, and those can point to derived class objects.