"Rasmus" <nonexistent@ho tmail.com> wrote in message news:<bg61iq$2s 5b$1@jarjarbink s.mobilixnet.dk >...[color=blue]
> Hi, here a quick question:
>
> I have class A,B,C where B and C is extended from A.
>
> I would like to construct A objects like:
>
> A *a3 = new A(a1, a2);
>
> and a3 should be an object of type B or C.
>
> Is this possible?
> | true: How?
> | false: Can you give me a nice solution?
>
> Thanks for your time
> Rasmus[/color]
A* a3 = new B(a1, a2);
A* a4 = new C(a1, a2);
provided B and C have such constructors. If not, use the apropriate
constructors for B and C.
/dan
> Hi, here a quick question:
>
> I have class A,B,C where B and C is extended from A.
>
> I would like to construct A objects like:
>
> A *a3 = new A(a1, a2);
>
> and a3 should be an object of type B or C.
>
> Is this possible?
> | true: How?
> | false: Can you give me a nice solution?
>
> Thanks for your time
> Rasmus[/color]
A* a3 = new B(a1, a2);
A* a4 = new C(a1, a2);
provided B and C have such constructors. If not, use the apropriate
constructors for B and C.
/dan