首先我很抱歉格式,这是我第一次在这个网站上发布。下面是我的程序的开始,它只是一个简单的菜单,它具有不同的排序和搜索以及创建列表的方式。当我尝试在我的项目列表上使用.empty时,我的错误在于菜单方法。我得到了非类型成员的错误请求。我只是在编程的第二年,所以试图解释,像我是一个白痴大声笑。请求会员,这是非班级类型使用.empty或.size
const int MLS = 50;
typedef int element;
const element SENTINEL = -1;
element read_element();
int read_int();
class AList{
private:
element items[MLS];
int size;
void Swap(int pos1, int pos2);
bool sorted;
public:
void Read();
void GenerateRandomList();
void Print();
void BubbleSort();
void InsertionSort();
void SelectionSort();
void LinearSearch(element target);
void BinarySearch(element target);
void Menu();
};
int main(){
AList A;
A.Menu();
}
void AList::Menu(){
int choice;
element target;
cout << "Current list: ";
if (items.empty == true)
cout << "(empty)";
else
Print();
if (sorted == true)
cout << "(KNOWN to be ordered)" << endl << endl;
else
cout << "(NOT KNOWN to be ordered)" << endl << endl;
cout << "Actions:" << endl;
cout << " 1. Reset the current list from the keyboard" << endl;
cout << " 2. Reset the current list using randomly generated ";
请正确格式化您的代码。你可以在这里找到帮助(https://stackoverflow.com/help/formatting)。 –
无论在这里新增什么,您都可以使用1360万个现有问题来查看应该看到的问题。 –