• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 15-Day Money-Back Guarantee

C++ Equivalent to VB Constructors & Finalizers

The implementation of the 'Dispose' method in the IDisposable interface can be converted to a C++ destructor, but this is not exactly equivalent.

VB C++
Class Foo
    Implements System.IDisposable

    Public Sub New()
        Me.New(0)   'call to other constructor
    End Sub
    Public Sub New(i As Integer)
    End Sub

    Public Sub Dispose() Implements System.IDisposable.Dispose
    End Sub

    Protected Overrides Sub Finalize() ''finalizer' method
    End Sub
End Class
class Foo
{
public:
    Foo() : Foo(0)   //call to other constructor
    {
    }
    Foo(int i)
    {
    }

    ~Foo()   //destructor
    {
    }

private:
//VB TO C++ CONVERTER WARNING: There is no equivalent in C++ to finalizer methods:
    void Finalize()
    {
    }
};


Use VB to C++ Converter to convert from VB to C++.     

Additional resource: VB.NET and C++ Equivalents


Copyright © 2004 – 2021 Tangible Software Solutions, Inc.