In reply to SANJAIKUMAR:
- In your associative array declaration, you have specified a class variable obj, not the required class type AB, as the index type. See this for the difference.
- Your array declaration needs to come after declaring the class type.
- Access the class member a using class_name[obj].a