Problem with multiple constructors

T

Tupolev

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
 
K

Karl Heinz Buchegger

Tupolev said:
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 );
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top