Constructor chaining MC++

  • Thread starter Thread starter Daniel =?iso-8859-1?Q?Lidstr=F6m?=
  • Start date Start date
D

Daniel =?iso-8859-1?Q?Lidstr=F6m?=

Hi,

how do I accomplish this using MC++?

public LandXML() : this(DateTime.Now)
{ }
public LandXML(DateTime now)
{
....
}

Problem is I don't know how to call the other constructor.
 
LandXML obj = new LandXML(DataTime.Now);

No, not what I asked for. This is in CS and does not show constructor
chaining. I want to know how to do constructor chaining using Managed C++,
i.e. how to call one constructor from another.
 
Daniel Lidström said:
No, not what I asked for. This is in CS and does not show constructor
chaining. I want to know how to do constructor chaining using Managed C++,
i.e. how to call one constructor from another.

I don't think that you can, rather you need to create a private initalizer
function which you call from both constructors.

Just by the way, you can use the initializer syntax to invoke a base class
constructor but that's not what you asked.

Regards,
Will
 
You can't do this in C++ (MC++ or otherwise). A common way of getting round
this is to use the manufacture pattern, since you can chain multiple
manufacture calls, so you'd have:

LandXML Manufacture()
{
return Manufacture( DateTime.Now );
}

LandXML Manufacture( DateTime )
{
}

Steve
 
Daniel said:
No, not what I asked for. This is in CS and does not show constructor
chaining. I want to know how to do constructor chaining using Managed C++,
i.e. how to call one constructor from another.

This was cut from Whidbey. While we had plans to do this, the ISO C++
committee started playing around with this feature and making changes to the
design. Rather than rush changes into our design, we cut it from the
product. When we know that the ISO C++ committee is settled on a design,
we'll look at bringing this back.
 
This was cut from Whidbey. While we had plans to do this, the ISO C++
committee started playing around with this feature and making changes to the
design. Rather than rush changes into our design, we cut it from the
product. When we know that the ISO C++ committee is settled on a design,
we'll look at bringing this back.

Thanks for all your answers guys.
 
Back
Top