Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Compiler Warning (level 2) C4948

return type of 'accessor' does not match the last parameter type of the corresponding setter

The compiler found a mismatch between what data type is being get and set for an indexed property.

C4948 is only reachable using /clr:oldSyntax.

The following sample generates C4948:

// C4948.cpp
// compile with: /clr:oldSyntax /LD /W2

__gc class MyClass
{
   int prop __nogc [2];
   public:

      __property int get_P(int i)
      // try the following line instead
      // __property char get_P(int i)
      {
         return prop[i];
      }

      __property void set_P(int i, char c)
      {
         prop[i] = c;
      }
};   // C4948
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.