• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 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: Unlike VB, there is no automatic call to this finalizer method in native C++:
    void Finalize()
    {
    }
};


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

Additional resource: VB.NET and C++ Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.