Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Problem with multiple constructors

Reply
Thread Tools

Problem with multiple constructors

 
 
Tupolev
Guest
Posts: n/a
 
      06-24-2003
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


 
Reply With Quote
 
 
 
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      06-24-2003


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
reg constructors/copy constructors inheritance srp113 C++ 3 02-17-2009 04:01 PM
Is the possible to have all the public constructors of the publicbase class as the constructors of a derived class? Peng Yu C++ 5 09-19-2008 10:19 AM
compiler synthesized constructors/copy constructors/assignment operators Jess C++ 5 06-07-2007 11:09 AM
Copy constructors, de/constructors and reference counts Jeremy Smith C++ 2 08-02-2006 11:25 PM
Constructors that call other Constructors Dave Rudolf C++ 12 02-06-2004 03:26 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57