Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Warning (level 2) C4948

Error Message

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

Community Additions

ADD
Show:
© 2015 Microsoft