Computer Science Canada

Error with my instance class.

Author:  copthesaint [ Wed Oct 07, 2009 12:00 pm ]
Post subject:  Error with my instance class.

I keep getting the errors int/double cannot be reffered.
Any help? The files are commented, and any other you find will be great to share Smile

Author:  Vermette [ Wed Oct 07, 2009 12:13 pm ]
Post subject:  Re: Error with my instance class.

You're trying to call a method on a primitive due to a scope mismatch.

Java:
public void setInt (String name,int value, int arrayPart){
         int [] lastInt = new int [2];//records the place of the last holder to save speed.
         lastInt [0] = 0;
         lastInt [1] = arrayPart;
         lastInt = value.modifyIntInstance(name,value,lastInt);// changes the value of an int.
      }


Your intent here was to call the InstanceSetup value in your class attribute, but due to scoping rules, you're actually trying to make a method call on the method parameter value, which is a primitive. Object-scope your method call with the this keyword:

Java:
public void setInt (String name,int value, int arrayPart){
         int [] lastInt = new int [2];//records the place of the last holder to save speed.
         lastInt [0] = 0;
         lastInt [1] = arrayPart;
         lastInt = this.value.modifyIntInstance(name,value,lastInt);// changes the value of an int.
      }


But better yet, change the name of the parameter.

Author:  copthesaint [ Fri Oct 09, 2009 2:06 pm ]
Post subject:  RE:Error with my instance class.

kk thanks Vermette


: