E2492 Properties may only be assigned using a simple statement, e.g. \"prop = value;\" (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Compiler Errors And Warnings (C++) Index

Assignments to properties should be made in simple assignment statements. If property assignments could become Lvalues, which happens when property assignments are embedded in larger statements, the getter is called to create the Lvalue, with all the side effects that getter causes. The compiler allows only one call to either the getter or the setter in a statement.

For example:

class myClass
{
  int X;
  public:
  int __property x = { read=getx, write=putx };
  int getx() { return X; }
  void putx(int val) { X = val; }
} OneClass;
int value(int);
int main()
{
  return value(OneClass.x = 4);  // This causes an error
}