• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

C++ Equivalent to VB Shared Constructors

The C++ equivalent to a VB shared constructor uses a private nested class.

VB C++
Class Foo
    Public Shared field As Integer

    Shared Sub New()
        field = 1
    End Sub
End Class
class Foo
{
public:
    static int field;

private:
    class StaticConstructor
    {
    public:
        StaticConstructor()
        {
            field = 1;
        }
    };

private:
    static Foo::StaticConstructor staticConstructor;
};


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


Copyright © 1997 – 2017 Tangible Software Solutions Inc.