2013-05-16 3 views
-1

세 가지 보충 멤버 함수를 제외하고는 작동하는 클래스를 만들었습니다. 다른 모든 공용 멤버 함수에서 개인 데이터 멤버를 참조하고 필요한 데이터에 액세스하는 데 아무런 문제가 없습니다. 그러나이 세 가지 특정 함수를 사용하여 Dev C++ 컴파일러는 다음과 같이 응답합니다. " 'matrix'는 선언되지 않았으므로이 함수를 먼저 사용하십시오 (행렬은 개인 데이터 멤버입니다.) 클라이언트 프로그램과 3 가지 함수에서 잘 작동하는 샘플 함수를 첨부했습니다. 문제 아동컴파일 오류 : 실제로 선언 된 선언되지 않은 멤버

bool boolMatrix::get(int row, int col) const{ 
    assert (row < ROW_SIZE && col < COL_SIZE);  

    if(matrix[row][col]){ 
     return true; 
    } 
    else 
     return false; 
} 


int rowCount(int row){ 
    int trueCount = 0; 
    assert(row < ROW_SIZE); 
    for (int colCount = 0; colCount < COL_SIZE; colCount++){ 
     if(matrix[row][colCount]){ 
      trueCount++; 
     } 
    } 

    return trueCount; 
} 



int colCount(int col){ 
    int trueCount = 0; 
    assert(col < COL_SIZE); 

    for (int rowCount = 0; rowCount < ROW_SIZE; rowCount++){ 
     if(matrix[rowCount][col]){ 
      trueCount++; 
     } 
    } 

    return trueCount; 
} 



int totalCount(){ 
    int trueCount = 0; 
    for (int rowCount = 0; rowCount < ROW_SIZE; rowCount++){ 
     for (int colCount = 0; colCount < COL_SIZE; colCount++){ 
      if (matrix[rowCount][colCount]){ 
       trueCount++; 
      } 
     } 
    } 

    return trueCount; 
} 

답변

0

추가 "boolMatrix ::"에서는 totalCount()와 COLCOUNT (INT의 COL)

+0

나는 그런 바보입니다 –

+0

에 그냥 커피 또는 맥주 (있는 경우 허용) 한 잔이 필요합니다.. :) – Arun