473,698 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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):Telle r(base); error: TellerInc undeclared

greatings Tupolev
Jul 19 '05 #1
1 4378


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::Tell erInc( 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
5311
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 dimensions (rows/columns)). Even if Python couldn't resolve the __init__ to use on the basis of argument types surely it could do so on the basis of argument numbers??? At any rate - any suggestions how I code this????
4
5868
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
5372
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 I'm experiencing is that when many users are hitting the site at once, occasionaly I will see errors. The 3 most common ones are: "The SqlCommand is currently busy Open, Fetching. ", "Internal Connection Fatal Error", "object reference not set to...
2
3102
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 initializer lists have to be cut and pasted from one constructor to another. This does not seem to lend itself particularly well to maintainablility. Calling a constructor from another in C++ is not legal unlike in Java. Also, functions other...
0
298
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 tried numerous attributes with no success. Any help would be appreciated... using System; using System.IO; using System.Text; using System.Xml;
14
3615
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 should not be. But if I compile with g++-4.0.3 the following snippet: class A { int i;
7
16556
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 called "Point" which would have two values "x" and "y". Now, let's say if it were the Java version, I would want two constructors: one that accept two numbers, the other accepts a string:
5
2270
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 during linking I get: What am I doing wrong?
3
2551
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 used, then "the responsibility for initializing a virtual base is borne by the most derived class in the hierarchy". What does it mean? Initializing base class is usually done automatically by the compiler, but a derived class can invoke the base...
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.