编译器错误 C3901

“accessor_function”:必须具有返回类型“type”

至少一个 get 方法的返回类型必须与属性类型匹配。 有关详细信息,请参阅 property

以下示例生成 C3901:

// C3901.cpp
// compile with: /clr /c
using namespace System;
ref class X {
   property String^ Name {
      void get();   // C3901
      // try the following line instead
      // String^ get();
   };
};

ref class Y {
   property double values[int, int] {
      int get(int, int);   // C3901
      // try the following line instead
      // double get(int, int);
   };
};