<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Visual_C%2B%2B_.NET%2FClass%2Finterface</id>
		<title>Visual C++ .NET/Class/interface - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Visual_C%2B%2B_.NET%2FClass%2Finterface"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Visual_C%2B%2B_.NET/Class/interface&amp;action=history"/>
		<updated>2026-04-29T17:48:29Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Visual_C%2B%2B_.NET/Class/interface&amp;diff=3608&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Visual_C%2B%2B_.NET/Class/interface&amp;diff=3608&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:02Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Visual_C%2B%2B_.NET/Class/interface&amp;diff=3609&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Visual_C%2B%2B_.NET/Class/interface&amp;diff=3609&amp;oldid=prev"/>
				<updated>2010-05-26T12:05:38Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==base and interface==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
using namespace System;&lt;br /&gt;
ref class MyClass{&lt;br /&gt;
   public:&lt;br /&gt;
      virtual void f() { Console::WriteLine(&amp;quot;MyClass::f&amp;quot;); }&lt;br /&gt;
      virtual void g() { Console::WriteLine(&amp;quot;MyClass::g&amp;quot;); }&lt;br /&gt;
};&lt;br /&gt;
interface class MyInterface{&lt;br /&gt;
   void f();&lt;br /&gt;
   void g();&lt;br /&gt;
};&lt;br /&gt;
ref class C : MyClass, MyInterface{&lt;br /&gt;
   public:&lt;br /&gt;
   virtual void f() new{&lt;br /&gt;
      Console::WriteLine(&amp;quot;C::f&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
   virtual void g() override{&lt;br /&gt;
      Console::WriteLine(&amp;quot;C::g&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
};&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   MyClass^ b = gcnew MyClass();&lt;br /&gt;
   C^ c = gcnew C();&lt;br /&gt;
   MyInterface^ i = c;&lt;br /&gt;
   b-&amp;gt;f(); // calls MyClass::f&lt;br /&gt;
   c-&amp;gt;f(); // calls C::f&lt;br /&gt;
   i-&amp;gt;f(); // calls C::f since C::f implements MyInterface::f&lt;br /&gt;
   MyClass^ bc = c;  // b pointing to instance of C&lt;br /&gt;
   bc-&amp;gt;f(); // calls MyClass::f since C::f is unrelated&lt;br /&gt;
   b-&amp;gt;g();  // calls MyClass::g&lt;br /&gt;
   c-&amp;gt;g();  // calls C::g&lt;br /&gt;
   i-&amp;gt;g();  // calls C::g since C::g implements MyInterface::g&lt;br /&gt;
   bc-&amp;gt;g(); // calls C::g since C::g overrides MyClass::g&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==class interface method ambiguity==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
using namespace System;&lt;br /&gt;
interface class MyInterface{&lt;br /&gt;
   void f();&lt;br /&gt;
};&lt;br /&gt;
ref class MyClass : MyInterface{&lt;br /&gt;
   public:&lt;br /&gt;
   void f()&lt;br /&gt;
   {&lt;br /&gt;
     Console::WriteLine(&amp;quot;MyClass::f&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
   virtual void fMyInterface() = MyInterface::f&lt;br /&gt;
   {&lt;br /&gt;
     Console::WriteLine(&amp;quot;MyClass::fMyInterface implementing MyInterface::f&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
};&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   MyClass^ a = gcnew MyClass();&lt;br /&gt;
   MyInterface^ ia = a;&lt;br /&gt;
   ia-&amp;gt;f();&lt;br /&gt;
   a-&amp;gt;f();&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==constants in interfaces==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
interface class I&lt;br /&gt;
{&lt;br /&gt;
   static const int i = 100;     // OK : static members OK&lt;br /&gt;
   literal int j = 50;           // OK : literals OK&lt;br /&gt;
};&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Explicit interface implementation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
using namespace System;&lt;br /&gt;
interface class MyInterface1 { void f(); };&lt;br /&gt;
interface class MyInterface2 { void f(); };&lt;br /&gt;
ref class MyClass : MyInterface1, MyInterface2&lt;br /&gt;
{&lt;br /&gt;
   public:&lt;br /&gt;
   virtual void f1() = MyInterface1::f&lt;br /&gt;
   {&lt;br /&gt;
      Console::WriteLine(&amp;quot;MyClass::f1 == MyInterface1::f&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
   virtual void f2() = MyInterface2::f&lt;br /&gt;
   {&lt;br /&gt;
      Console::WriteLine(&amp;quot;MyClass::f2 == MyInterface2::f&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
};&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   MyClass^ r = gcnew MyClass();&lt;br /&gt;
   MyInterface1^ i1 = r;&lt;br /&gt;
   MyInterface2^ i2 = r;&lt;br /&gt;
   r-&amp;gt;f1();       // OK -- call through the object.&lt;br /&gt;
   r-&amp;gt;f2();       // OK -- call through the object.&lt;br /&gt;
&lt;br /&gt;
   i1-&amp;gt;f();       // OK -- call f1.&lt;br /&gt;
   i2-&amp;gt;f();       // OK -- call f2.&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Interface and class(The virtual keyword is required to implement the interface method)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
interface class IInterface&lt;br /&gt;
{&lt;br /&gt;
   void f();&lt;br /&gt;
   int g();&lt;br /&gt;
};&lt;br /&gt;
ref class MyClass : IInterface&lt;br /&gt;
{&lt;br /&gt;
   public:&lt;br /&gt;
      virtual void f() { }&lt;br /&gt;
      virtual int g() { return 1; }&lt;br /&gt;
};&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Interface definition==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
using namespace System;&lt;br /&gt;
interface class Interface1&lt;br /&gt;
{&lt;br /&gt;
    void Method1();&lt;br /&gt;
    void Method2();&lt;br /&gt;
};&lt;br /&gt;
interface class Interface2&lt;br /&gt;
{&lt;br /&gt;
    void Method3();&lt;br /&gt;
    property String^ X;&lt;br /&gt;
};&lt;br /&gt;
ref class Base&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    void MethodBase()&lt;br /&gt;
    {&lt;br /&gt;
        Console::WriteLine(&amp;quot;MethodBase()&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
ref class DerivedClass : public Base, public Interface1, public Interface2&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    virtual property String^ X&lt;br /&gt;
    {&lt;br /&gt;
        String^ get()&lt;br /&gt;
        {&lt;br /&gt;
            return x;&lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
        void  set(String^ value)&lt;br /&gt;
        {&lt;br /&gt;
            x = value;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    virtual void Method1()&lt;br /&gt;
    {&lt;br /&gt;
        Console::WriteLine(&amp;quot;Method1()&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    virtual void Method2()&lt;br /&gt;
    {&lt;br /&gt;
        Console::WriteLine(&amp;quot;Method2()&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    virtual void Method3()&lt;br /&gt;
    {&lt;br /&gt;
        Console::WriteLine(&amp;quot;Method3()&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    virtual void Print()&lt;br /&gt;
    {&lt;br /&gt;
        MethodBase();&lt;br /&gt;
        Method1();&lt;br /&gt;
        Method2();&lt;br /&gt;
        Method3();&lt;br /&gt;
    }&lt;br /&gt;
private:&lt;br /&gt;
    String^ x;&lt;br /&gt;
};&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
    DerivedClass dc;&lt;br /&gt;
    dc.X = &amp;quot;asdf&amp;quot;;&lt;br /&gt;
    Console::WriteLine(dc.X);&lt;br /&gt;
    dc.Print();&lt;br /&gt;
} &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Interface list==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
using namespace System;&lt;br /&gt;
interface class MyInterface {};&lt;br /&gt;
interface class MyInterfaceB {};&lt;br /&gt;
ref class Base : MyInterface   // OK&lt;br /&gt;
{ };&lt;br /&gt;
ref class Derived : Base, MyInterface  // OK : Base class first&lt;br /&gt;
{ };&lt;br /&gt;
ref class A : Object, MyInterface  // OK: Object may be explicitly stated.&lt;br /&gt;
{ };&lt;br /&gt;
value class V : ValueType, MyInterface  // OK: Value class inherits from ValueType.&lt;br /&gt;
{ };&lt;br /&gt;
ref class B : MyInterfaceB, Base  // OK. Base class need not appear first (as in C#).&lt;br /&gt;
{ };&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Interface name collision==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
using namespace System;&lt;br /&gt;
interface class MyInterface1 { void f(); };&lt;br /&gt;
interface class MyInterface2 { void f(); };&lt;br /&gt;
ref class MyClass : MyInterface1, MyInterface2&lt;br /&gt;
{&lt;br /&gt;
   public:&lt;br /&gt;
   virtual void f()&lt;br /&gt;
   { Console::WriteLine(&amp;quot;MyClass::f&amp;quot;); }&lt;br /&gt;
};&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   MyClass^ r = gcnew MyClass();&lt;br /&gt;
   r-&amp;gt;f();  // MyClass::f() implements both MyInterface1&amp;quot;s f and MyInterface2&amp;quot;s f&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Interface properties events==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
using namespace System;&lt;br /&gt;
interface class MyInterface&lt;br /&gt;
{&lt;br /&gt;
   property int P1;&lt;br /&gt;
   event EventHandler^ E;&lt;br /&gt;
   property int P2&lt;br /&gt;
   {&lt;br /&gt;
      int get();&lt;br /&gt;
      void set(int v);&lt;br /&gt;
   }&lt;br /&gt;
};&lt;br /&gt;
ref class MyClass : MyInterface&lt;br /&gt;
{&lt;br /&gt;
   int value;&lt;br /&gt;
   public:&lt;br /&gt;
   virtual property int P1;&lt;br /&gt;
   virtual event EventHandler^ E;&lt;br /&gt;
   virtual property int P2&lt;br /&gt;
   {&lt;br /&gt;
      int get() { return value; }&lt;br /&gt;
      void set(int v) { value = v; }&lt;br /&gt;
   }&lt;br /&gt;
};&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==interfaces implementing interfaces==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
interface class MyInterface { void f(); };&lt;br /&gt;
interface class IB : MyInterface { void g(); };&lt;br /&gt;
ref class MyClass : IB&lt;br /&gt;
{&lt;br /&gt;
   public:&lt;br /&gt;
      virtual void f() {}&lt;br /&gt;
      virtual void g() {}&lt;br /&gt;
};&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==multiple interfaces==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
interface class MyInterface { void f(); };&lt;br /&gt;
interface class IB { void g(); };&lt;br /&gt;
ref class MyClass : MyInterface, IB&lt;br /&gt;
{&lt;br /&gt;
   public:&lt;br /&gt;
      virtual void f() {}&lt;br /&gt;
      virtual void g() {}&lt;br /&gt;
};&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Private interface==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
interface class IInterface&lt;br /&gt;
{&lt;br /&gt;
   void f();&lt;br /&gt;
   int g();&lt;br /&gt;
};&lt;br /&gt;
ref class MyClass : IInterface&lt;br /&gt;
{&lt;br /&gt;
      virtual void f() sealed = IInterface::f&lt;br /&gt;
      { }&lt;br /&gt;
   public:&lt;br /&gt;
      virtual int g() { return 1; }&lt;br /&gt;
};&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   MyClass^ r = gcnew MyClass();&lt;br /&gt;
   IInterface^ ir = r;&lt;br /&gt;
   ir-&amp;gt;f();  // f may be called through the interface.&lt;br /&gt;
   r-&amp;gt;g();     // OK&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==static interfaces==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
using namespace System;&lt;br /&gt;
interface class MyInterface&lt;br /&gt;
{&lt;br /&gt;
   static int i = 6;&lt;br /&gt;
   static const int j = 100;&lt;br /&gt;
   static void f()  { Console::WriteLine(&amp;quot;MyInterface::f &amp;quot; + i); }&lt;br /&gt;
};&lt;br /&gt;
ref class A : MyInterface&lt;br /&gt;
{&lt;br /&gt;
   public:&lt;br /&gt;
   static void f() { Console::WriteLine(&amp;quot;A::f &amp;quot; + MyInterface::j); }&lt;br /&gt;
};&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   A^ a = gcnew A();&lt;br /&gt;
   MyInterface^ ia = a;&lt;br /&gt;
   ia-&amp;gt;f();    &lt;br /&gt;
   a-&amp;gt;f();     &lt;br /&gt;
   MyInterface::f();&lt;br /&gt;
   A::f();      &lt;br /&gt;
   a-&amp;gt;MyInterface::f();&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>