Informix Error -4004: Member "name" of class "class-name" cannot be accessed in this context.
Cause and resolution
Member "name" of class "class-name" cannot be accessed in this context.
The compiler is aware of the member, but the access control for the member makes it inaccessible in the statement. Check for a PUBLIC, PRIVATE, or PROTECTED declaration. Member variables default to PROTECTED access, but member constants and member functions default to PUBLIC.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4004 fires when code outside a class's permitted access scope references one of its
members — per the official guidance, the compiler knows the member exists, but its access
control (PUBLIC, PRIVATE, or PROTECTED) makes it inaccessible from this statement. Member
variables default to PROTECTED; member constants and functions default to PUBLIC.
- A member accessed from outside its
PRIVATE/PROTECTEDscope, per the official guidance — the direct, only cause.
Solutions / Resolution
- Check for a
PUBLIC,PRIVATE, orPROTECTEDdeclaration on the member, per the official guidance, and adjust either the access level or the accessing code's location.
Examples
Accessing a PROTECTED member variable from outside the class
CLASS Order
DEFINE total DECIMAL -- defaults to PROTECTED
END CLASS
DEFINE o Order
LET total = o.total -- -4004: total is PROTECTED
Corrected
CLASS Order
DEFINE PUBLIC total DECIMAL
END CLASS
Diagnostic Checks
- Check the accessed member's declared (or default) access level, and confirm the accessing code is within a permitted scope, or adjust the access level.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -4004 in this set yet.
A class member is accessed from outside its PRIVATE/PROTECTED scope — check its access
level and where it's being accessed from.