Visual C++ .NET/Class/static method

Материал из .Net Framework эксперт
Версия от 12:05, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Static Method demo

 
#include "stdafx.h"
using namespace System;
ref class MyClass
{
private:
    static int x = 42;
public:
   static int get_x()
   {
      return x;
   }
};
void main()
{
    Console::WriteLine ( MyClass::get_x() );
}