Ticket Created
over 5 years ago

WERETECH-9125

Use of nested classes in Monkey C

I am trying to set up a data structure of an ANT device, and would like to use a sytem of nested classes for the data structure, so for example you would have a sensor data object, with a "page 20" property, which itself has "event count", "temperature" etc properties.  There are multiple pages in the ANT profile so being able to do this would keep things simpler than a flat data structure.

However this is giving a runtime error on initialization of the parent class.  Example code below gives error: Could not find symbol 'child_class'

Code below shows .  What am I doing wrong?

*** EDITED - Typo in original post, but not source of problem.  Code simplified to illustrate issue ***

    class child_class
    {
    	var x;
    	var y;
    	function initialize()
    	{
    		x=0;
    		y=0;
    	}
    }
    
    class parent_class
    {
    	var z;
    	var child;
    	function initialize()
    	{
    		z=0;
    		child = new child_class();
    	}
    }

Parents Comment Children