How do I: Simulate C# Constructor chaining in Managed C++

R

Russell Mangel

Hi,
I am trying to convert a C# class to Managed C++. The C# class derives from
System.Exception and uses constructor chaining.
I understand that C++ does not support constructor chaining. I am using
VS2003.

Can someone please check my C++ version to see if it is reasonably close to
the C# version?

// The original C# class
using System;
namespace JustATest
{
public sealed class MyException : Exception
{
public MyException() : base() {}
// The following Constructor uses Constructor chaining
public MyException(String message) : this(message, null) {}
public MyException(String message, Exception innerException) :
base(message, innerException) {}
}
}

// Here is my equivalent C++ class
#pragma once
using namespace System;
namespace JustATest
{
public __sealed __gc class MyException : public Exception
{
public:
MyException() : System::Exception() {}
MyException(String* message) : Exception(message, NULL) {}
MyException(String* message, Exception* innerException) :
Exception(message, innerException) {}
};
}

Thanks
Russell Mangel
Las Vegas, NV
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top