|
|
|
|
- Reason
- Correction
- Examples
- Calling a method of a class instance in the click code of a button
- Using a global class member in the click code of a button
Error 1001: The operators: and:: can only be used in the methods of classes
You are trying to use the ':' and '::' operators at the beginning of a code line that does not belong to a class process. Reminder: - The ':' character is used to access a member or a method of the instance of the current class or base class.
- The '::' characters are used to access a member, a method or a global constant of the current class or base class.
- To access a member or a method of a class instance from a code that does not belong to this class (or to a derived class), the member or the method must be prefixed by the variable corresponding to the instance of the class.
- To access a member, a method or a global constant of a class from a code that does not belong to this class (or to a derived class), the member (the method or the constant) must be prefixed by the name of the class.
Calling a method of a class instance in the click code of a button Code triggering the error
// -- Click code on BTN_Button1 clInstance is Class1 :Méthod1()
Possible correction Prefix the method by the name of the instance.
// -- Click code on BTN_Button1 clInstance is Class1 clInstance:Method1()
Using a global class member in the click code of a button Code triggering the error
// -- Click code on BTN_Button1 ::GlobalMember1 = 5
Possible correction Prefix the member by the name of the class.
// -- Click code on BTN_Button1 Class1::GlobalMember1 = 5
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|