Vector<Medicine*>* Controller::sortByStockAsc(){
Vector<Medicine*>* all =repo->getAll();
qsort(all, all->getNrMed(),sizeof(Medicine*), (comparefunction) compareNA);
return all;}
我有上面的代码,我的qsort有一些问题。 Vector<Medicine*>*
是指向我需要整理的指针数组的指针。 getAll()
返回Vector <Medicine*>*
。 其中一个问题是,在qsort()
我的getNrMed()
没有找到,虽然我指定了定义此功能的模块。功能如下:C++中的Qsort困境
int MedRepository::getNrMed(){
return MedList->getSize();
}
并返回int
。我做错了什么?
什么是'Vector'?你使用'qsort'似乎是错误的。 – 2013-05-07 18:11:39
'class Vector { private: \t T * Elems; \t int Size; \t int Capacity;' +构造函数,析构函数和getter – Matt 2013-05-07 18:13:08
您可能想描述“我的qsort有一些问题”是什么意思,是否因为无法支付抵押贷款而抑郁?使用'std :: sort()',因为'qsort()'使用'memcpy()'来交换对象,这并不总是适用于C++对象。 – 2013-05-07 18:24:25