2014-12-04 38 views
1
public char[] Cache_1(int word_address,int cache_set,int ls,char[] s1) 
{ 
    char cache_1[][] = new char[32][4]; 

    char s0[] = new char[32]; 
    InterConnectionNetwork ic = new InterConnectionNetwork(); 

    if(ls == '0') { 
     if((cache_1[cache_set][0]) == '1') { // Check Valid Bit and transfer content 
              // if valid bit is high 
      for(int i=0;i<32;i++) {   // Load 
       s0[i] = cache_1[cache_set][i]; 
      } 
     } else {        // Valid bit low 
      s0 = ic.determinenode(word_address);      
     }    
     return s0; 
    } else {   
     if((cache_1[cache_set][0]) == '1') { 
      for(int i=0;i<32;i++) { 
       cache_1[cache_set][i] = s0[i]; 
      } 
     } else 
      cache_1[cache_set][] = ic.determinenode(word_address); //returns char[]  
     return (cache_1[cache_set][]);  //Problem here 
    }   
} 

這是我寫的代碼塊。這裏的問題是使用的返回類型是char[]cache_1[cache_set][]實際上等價於單個字符數組,但它顯示錯誤。請幫我解決它。char []代碼中的返回類型不接受char [i] []值

回答

3

您應該返回cache_1[cache_set]而不是cache_1[cache_set][]

+0

我相信解決問題,謝謝Eran :) – 2014-12-04 11:13:39

0

你定義的返回類型

char[] 

這意味着字符數組(線性)

和你正在返回

cache_1[cache_set][] //should give multiple error and one for not giving index inside the second [?] 

如果寫此正確,那麼你正在返回的charchar[] 你必須改變它中的任何一個。

相關問題