Problem with multiple constructors

Discussion in 'C++' started by Tupolev, Jun 24, 2003.

  1. Tupolev

    Tupolev Guest

    Hello, can anyone give me a solution for the following problem?????????

    I have a class Teller with two possible constructors : Teller() and
    Teller(int base)
    Then I have a class TellerInc that is based on the class Teller, also with
    two possible constructors: TellerInc() and TellerInc(int step).
    Into the main I want to create an object of TellerInc and give a value for
    the step and the base (thus I have to create the TellerInc(int step) that
    gets the Teller(int base))

    The header file of Teller:
    class Teller
    {
    public:
    ~Teller();
    Teller();
    Teller(int base);
    };


    The header file of Tellerinc:
    #include "teller.hpp"
    class TellerInc : public Teller
    { public:
    int stepgetal;
    TellerInc();
    ~TellerInc();
    TellerInc(int step)
    };

    Into the main:
    TellerInc tel(step):Teller(base); error: TellerInc undeclared

    greatings Tupolev
     
    Tupolev, Jun 24, 2003
    #1
    1. Advertising

  2. Tupolev wrote:
    >
    > Hello, can anyone give me a solution for the following problem?????????
    >
    > I have a class Teller with two possible constructors : Teller() and
    > Teller(int base)
    > Then I have a class TellerInc that is based on the class Teller, also with
    > two possible constructors: TellerInc() and TellerInc(int step).
    > Into the main I want to create an object of TellerInc and give a value for
    > the step and the base (thus I have to create the TellerInc(int step) that
    > gets the Teller(int base))


    Then TellerInc needs another constructor with 2 arguments:
    * the step, which is used by TellerInc
    * the base, which is passed to Teller

    > class TellerInc : public Teller
    > { public:
    > int stepgetal;
    > TellerInc();
    > ~TellerInc();
    > TellerInc(int step)


    TellerInc( int step, int base );

    > };
    >


    TellerInc::TellerInc( int step, int base ) : Teller( base )
    {
    ....
    }


    int main()
    {
    TellerInc( 3, 4 );

    --
    Karl Heinz Buchegger
     
    Karl Heinz Buchegger, Jun 24, 2003
    #2
    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. Dave Rudolf
    Replies:
    12
    Views:
    8,308
    Martijn Lievaart
    Feb 6, 2004
  2. Jeremy Smith
    Replies:
    2
    Views:
    592
    Jeremy Smith
    Aug 3, 2006
  3. Jess
    Replies:
    5
    Views:
    611
    Ron Natalie
    Jun 7, 2007
  4. Peng Yu
    Replies:
    5
    Views:
    401
    Juha Nieminen
    Sep 19, 2008
  5. srp113
    Replies:
    3
    Views:
    472
Loading...

Share This Page