473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with multiple constructors

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
Jul 19 '05 #1
1 4358


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
kb******@gascad.at
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Philip Smith | last post by:
Call this a C++ programmers hang-up if you like. I don't seem to be able to define multiple versions of __init__ in my matrix class (ie to initialise either from a list of values or from 2...
4
by: Jimmy Johns | last post by:
Hi, I have some classes as follows: #include <iostream> using namespace std; class A { public: virtual A* clone() const = 0; };
0
by: Bob | last post by:
I have an ASP.NET web application that has been running without any problems for a while. I recently transferred the site to shared hosting and had multiple users start to use the site. The problem...
2
by: Neil Zanella | last post by:
Hello, AFAIK the only way to initialize a reference variable defined inside a class is to initialize it in an initializer list. However, when there are multiple constructors, this means that the...
0
by: Gonzo | last post by:
I have the following code. When I serialize the DriverCollection I would like to get both the Driver Collection and the DeletedItems collection. I end up with only the Driver collection. I have...
14
by: dl | last post by:
I have two classes, say A and B, both having a data member 'int n'; private in A, public in B. When I derive class C from both public A and public B, B::n should be visible to C while A::n...
7
by: andrewfsears | last post by:
I have a question: I was wondering if it is possible to simulate the multiple constructors, like in Java (yes, I know that the languages are completely different)? Let's say that I have a class...
5
by: PaperPilot | last post by:
I have defined a vector and its iterator as such: typedef std::vector< WindsTableElement > WindTable; WindTable wt_; WindTable::iterator windIterator_; I get no errors during compile, but...
3
by: Jess | last post by:
Hello, I've been reading Effective C++ about multiple inheritance, but I still have a few questions. Can someone give me some help please? First, it is said that if virtual inheritance is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.