inheritance, pointercast

Discussion in 'C++' started by Rasmus, Jul 29, 2003.

  1. Rasmus

    Rasmus Guest

    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
     
    Rasmus, Jul 29, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. maxw_cc
    Replies:
    1
    Views:
    3,148
    Martijn van Steenbergen
    Dec 21, 2003
  2. Dan Cernat

    inheritance, pointercast

    Dan Cernat, Jul 31, 2003, in forum: C++
    Replies:
    0
    Views:
    304
    Dan Cernat
    Jul 31, 2003
  3. cppsks
    Replies:
    0
    Views:
    827
    cppsks
    Oct 27, 2004
  4. karthikbalaguru
    Replies:
    9
    Views:
    1,041
  5. Daniel Pitts
    Replies:
    27
    Views:
    1,908
    Mike Schilling
    Feb 27, 2008
Loading...

Share This Page