We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › The nested type cannot hide an enclosing type
Page Index Toggle Pages: 1
The nested type cannot hide an enclosing type (Read 1439 times)
The nested type cannot hide an enclosing type
May 19th, 2010, 2:55pm
 
Hi I'm creating a mergesort visualization I'm getting this error . Here is the relevant code

class MergeSort{
//member Variables for the strobed version of the merge sort

int high, low, mid, a;

boolean m_bCheckingInnerloop;

MergeSort()
{
     InitStrobe();
}

void InitStrobe()
{
     high=0;
     m_bCheckingInnerloop=false;
}

//This is the original merge sort; for reference
//void merge(int,int,int);
void merge_sort(int [] inArray,int low,int high)
{
int mid;
if(low<high)
{
 mid=(low+high)/2;
 merge_sort(inArray,low,mid);
 merge_sort(inArray,mid+1,high);
 merge(inArray,low,mid,high);
}
}

void merge(int [] inArray, int low, int mid,int high)
{
int h,i,j,k;
h=low;
i=low;
j=mid+1;

while((h<=mid)&&(j<=high))
{
 if(a[h]<=a[j])
 {
  inArray[i]=a[h];
  h++;
 }
 else
 {
 inArray[i]=a[j];
  j++;
 }
 i++;
}
if(h>mid)
{
 for(k=j;k<=high;k++)
 {
  inArray[i]=a[k];
  i++;
 }
}
else
{
 for(k=h;k<=mid;k++)
 {
  inArray[i]=a[k];
  i++;
 }
}
for(k=low;k<=high;k++)
 {
  a[k]=inArray[k];
 }
}

}  


i havent created the strobed version yet, i just want to it compile without visualization
Re: The nested type cannot hide an enclosing type
Reply #1 - May 19th, 2010, 10:35pm
 
Using your code and only:
Code:
void setup() {
 size(256,256,P2D);
 noLoop();
}
void draw() {}

I get the following message:
Quote:
The type of the expression must be an array type but it resolved to int.

from the line "if(a[h]<=a[j]) {" inside merge().

Changing the definition of "a" to an int[] compiles, but I don't know if it will do what you want.
Page Index Toggle Pages: 1