• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 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
    static int field;

    class StaticConstructor
            field = 1;

    static Foo::StaticConstructor staticConstructor;

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.