这比我保证的声音更简单。我查过了其他帖子,但我还没有成功找到任何帖子。
我有一个方法AList::GenerateRandom()
:
void AList::GenerateRandom(){
int randomAmount;
int randomLimitHigh;
srand(int(time(0)));
cout << "\nResetting the current list using randomly generated elements.\n\n";
cout << "Enter the desired number of elements (0 to 50): " ;
randomAmount = ReadRandomAmount();
randomLimitLow = ReadRandomLimitLow();
randomLimitHigh = ReadRandomLimitHigh(randomLimitLow);
cout << "\n\nFinished resetting, " << randomAmount << "elements between" << randomLimitLow << " and " << randomLimitHigh << "randomly generated.\n\n";
}
在我决定最好包含randomLimitLow的值之前,一切正常。
现在我收到了这个含糊不清的错误:
Undefined symbols for architecture x86_64:
"AList::ReadRandomAmount()", referenced from:
AList::GenerateRandom() in AList-2fa708.o
"AList::ReadRandomLimitLow()", referenced from:
AList::GenerateRandom() in AList-2fa708.o
ld: symbol(s) not found for architecture x86_64
以下是其他方法的内容
int ReadRandomAmount(){
int randomAmount; // used to collect the user's input
cin >> boolalpha >> randomAmount;
while (! cin.good() || randomAmount < 0 || randomAmount > 50) {
cin.clear();
cin.ignore(80, '\n');
if(!cin.good()){
cout << "Invalid data type, should be an element ("
<< ELEMENT_NAME
<< "), try again: ";
} else
cout << "Invalid range type, should be within 0 and 50, try again: ";
cin >> boolalpha >> randomAmount;
}
return randomAmount;
}
int ReadRandomLimitLow(){
int randomLimitLow; // used to collect the user's input
cin >> boolalpha >> randomLimitLow;
while (! cin.good() || randomLimitLow < 0 || randomLimitLow > 2147483646) {
cin.clear();
cin.ignore(80, '\n');
if(!cin.good()){
cout << "Invalid data type, should be an element ("
<< ELEMENT_NAME
<< "), try again: ";
} else
cout << "Invalid range type, should be within 0 and 2147483646, try again: ";
cin >> boolalpha >> randomLimitLow;
}
return randomLimitLow;
}
int ReadRandomLimitHigh(int randomLimitLow){
int randomLimitHigh; // used to collect the user's input
cin >> boolalpha >> randomLimitHigh;
while (! cin.good() || randomLimitHigh < randomLimitLow || randomLimitHigh > 2147483647) {
cin.clear();
cin.ignore(80, '\n');
if(!cin.good()){
cout << "Invalid data type, should be an element ("
<< ELEMENT_NAME
<< "), try again: ";
} else
cout << "Invalid range type, should be within " << randomLimitLow << " and 2147483647, try again: ";
cin >> boolalpha >> randomLimitHigh;
}
return randomLimitHigh;
}
我如何确保ReadRandomLimitHigh()
只会获取大于ReadRandomLimitLow()