2013-05-16 77 views
-1

我已经创建了一个类,除了三个补充成员函数外,它应该可以正常工作。在所有其他公共成员函数中,我指的是私有数据成员,并且访问我需要的数据并不困难;但是,对于这三个特定的函数,Dev C++编译器会响应:“'matrix'未声明,首先使用此函数(矩阵是私有数据成员)。我附加了一个示例函数,该函数在我的客户机程序以及三问题儿童编译错误:实际声明的未声明成员

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