Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 1.06 KB

compiler-error-c3797.md

File metadata and controls

44 lines (35 loc) · 1.06 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Error C3797
Compiler Error C3797
11/04/2016
C3797
C3797
ab27ff34-8c1d-4297-b004-9e39bd3a4f25

Compiler Error C3797

'override': event declaration cannot have override specifier (should be placed on event add/remove/raise methods instead)

You cannot override a trivial event (an event without explicitly defined accessor methods) with another trivial event. The overriding event must define its behavior with accessor functions.

For more information, see event.

Example

The following sample generates C3797.

// C3797.cpp
// compile with: /clr /c
delegate void MyDel();

ref class Class1 {
public:
   virtual event MyDel ^ E;
};

ref class Class2 : public Class1 {
public:
   virtual event MyDel ^ E override;   // C3797
};

// OK
ref class Class3 : public Class1 {
public:
   virtual event MyDel ^ E {
      void add(MyDel ^ d) override {}
      void remove(MyDel ^ d) override {}
   }
};