constructor on inherited object

  • Thread starter Thread starter Jack Addington
  • Start date Start date
J

Jack Addington

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
 
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;
}
 
Back
Top