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

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
}
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!