Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 806 Bytes

initonly-cpp-cli.md

File metadata and controls

33 lines (26 loc) · 806 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: initonly (C++/CLI)
initonly (C++/CLI)
11/04/2016
initonly_cpp
initonly
initonly attribute [C++]
f745d7fa-dc08-46f1-9b97-0977be58a008

initonly (C++/CLI)

initonly is a context-sensitive keyword that indicates that variable assignment can occur only as part of the declaration or in a static constructor in the same class.

The following example shows how to use initionly:

// mcpp_initonly.cpp
// compile with: /clr /c
ref struct Y1 {
   initonly
   static int staticConst1;

   initonly
   static int staticConst2 = 0;

   static Y1() {
      staticConst1 = 0;
   }
};

See also

Classes and Structs