프로그램을 작성하려고하지만 개인 멤버 함수가 개인 데이터 멤버에 액세스 할 수없는 이유를 알 수 없습니다. 누군가 제발 도와 주겠습니까? 내 기능은 다음과 같습니다. nStock, capacity 및 slots []은 모두 개인 데이터 멤버이며 hashStr()은 private 함수입니다.개인 멤버 함수의 비 정적 멤버에 대한 잘못된 참조
private:
static unsigned int hashStr(char const * const symbol); // hashing function
bool search(char * symbol);
struct Slot
{
bool occupied;
Stock slotStock;
};
Slot *slots; // array of instances of slot
int capacity; // number of slots in array
int nStocks; // current number of stocks stored in hash table
내가 추가 정보를 제공 할 수 있는지 알려 주시기 바랍니다 :
bool search(char * symbol)
{
if (nStocks == 0)
return false;
int chain = 1;
bool found = false;
unsigned int index = hashStr(symbol) % capacity;
if (strcmp(symbol, slots[index].slotStock.symbol) != 0)
{
int start = index;
index ++;
index = index % capacity;
while (!found && start != index)
{
if(symbol == slots[index].slotStock.symbol)
{
found = true;
}
else
{
index = index % capacity;
index++;
chain++;
}
}
if (start == index)
return false;
}
return true;
}
여기 내 .H 파일의 개인 회원 섹션입니다.
예 : 컴파일러 오류 메시지가 무엇입니까? (구체적으로 어떤 코드 행이 참조됩니까?) –