473,480 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

constructor on inherited object

I am having a problem getting my inherited object to compile. I am trying
to add another variable to the constuctor and I cannot get past different
variations of the following message:

No overload for method 'dataObjAnc' takes '0' arguments... I tweak the code
and the 0 changes to 1 etc...

I've seen the thread in here about coding the constructor as
inheritedObjConstr( ... ) : this() but I cannot figure out how to pass the
required parameter for the base object down to the base for processing.

I understand that the compiler is telling me that it is trying to fall back
onto a default constructor but that it doesn't exist. What is the
recommended approach here. I doesn't seem like I should have to duplicate
the single parameter constructor in the child object...

This is what I have

class dataObjAnc
{
dataObjAnc(string name)
{
do somthing...
}

}

class detailDataObjAnc : dataObjAnc
{
dataObjAnc(string name, Int32 progID)
{
set progID
pass name to base constructor
}

thx

Nov 16 '05 #1
3 2269
This compiles but is this the correct way to be doing this?

public dataObjProgram(string objName) : base(objName){}
public dataObjProgram(string objName, Int32 progID) : this(objName)
{
programID = progID;
}

"Jack Addington" <ja********@shaw.ca> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I am having a problem getting my inherited object to compile. I am trying
to add another variable to the constuctor and I cannot get past different
variations of the following message:

No overload for method 'dataObjAnc' takes '0' arguments... I tweak the
code and the 0 changes to 1 etc...

I've seen the thread in here about coding the constructor as
inheritedObjConstr( ... ) : this() but I cannot figure out how to pass
the required parameter for the base object down to the base for
processing.

I understand that the compiler is telling me that it is trying to fall
back onto a default constructor but that it doesn't exist. What is the
recommended approach here. I doesn't seem like I should have to duplicate
the single parameter constructor in the child object...

This is what I have

class dataObjAnc
{
dataObjAnc(string name)
{
do somthing...
}

}

class detailDataObjAnc : dataObjAnc
{
dataObjAnc(string name, Int32 progID)
{
set progID
pass name to base constructor
}

thx

Nov 16 '05 #2
Jack Addington <ja********@shaw.ca> wrote:
I am having a problem getting my inherited object to compile. I am trying
to add another variable to the constuctor and I cannot get past different
variations of the following message:


<snip>

See http://www.pobox.com/~skeet/csharp/constructors.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
perfect... thx

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Jack Addington <ja********@shaw.ca> wrote:
I am having a problem getting my inherited object to compile. I am
trying
to add another variable to the constuctor and I cannot get past different
variations of the following message:


<snip>

See http://www.pobox.com/~skeet/csharp/constructors.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4

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

Similar topics

7
28967
by: Dominique | last post by:
Suppose I have: class A { A(int x, int y); }; and class B: public A {
3
4523
by: Jun | last post by:
I have following script <script> var Animal = function(name){ this.name = name; } Animal.prototype.eat = function (food) {
8
2963
by: trying_to_learn | last post by:
Why do we need to explicitly call the copy constructor and the operator = , for base class and member objects in composition? ....book says "You must explicitly call the GameBoard copy-constructor...
45
6304
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
8
3652
by: Mike - EMAIL IGNORED | last post by:
I have a class that may or may not be inherited. Its constructor calls a function that should be called only if the class is not inherited. Is there a way to tell, other than simply passing a...
2
3208
by: slolife | last post by:
See any problem with this code: Here's my Base page class: Public Class BasePage Inherits System.Web.UI.Page Protected m_NeedAlerts As Boolean Private Sub Page_Init(ByVal sender As...
6
359
by: =?Utf-8?B?T2xkQnV0U3RpbGxMZWFybmluZw==?= | last post by:
I forget the right syntax.... If I Have multiple signatures for a constructor, but I want each to call a "main" version of the constructor...I can't remember how to do this in C#.... public...
1
1360
by: appu | last post by:
Hi all, Suppose class A is inherited from class B and Class B is inherited from class C. Could anyone explain on how the C++ compiler construct the A object and how is A object destroyed by...
2
1428
by: tshad | last post by:
Using VB.Net VS 2003 I am getting the following message when I call my 2nd constructor. Too many arguments to 'Public Sub New()'. I have 2 constructors: **********************************...
0
7054
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
7102
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...
1
6756
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
7003
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...
0
5357
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,...
1
4798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4495
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...
0
3000
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
199
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...

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.