Vector<Medicine*>* Controller::sortByStockAsc(){
Vector<Medicine*>* all =repo->getAll();
qsort(all, all->getSize(),sizeof(Medicine*), (comparefunction) compareNA);
return all;
}
所以,我有以上这应该排序objects.I阵列功能得到错误多个制造商和类型转换
cannot convert 'Vector<Medicine*>' to 'Vector<Medicine*>*' in initialization
但是如果我把它写成Vector<Medicine*> all =repo->getAll();
我收到了一堆新对于第三行的错误(这是不存在,如果我有一,二号线以前的错误):
Multiple markers at this line
- Method 'getSize' could not be resolved
- Invalid arguments ' Candidates are: void qsort(void *, unsigned int, unsigned int, int (*)(const void *, const
void *)) '
- base operand of '->' has non-pointer type 'Vector<Medicine*>'
什么不对的,我该如何解决?
'repo-> getAll()'返回什么? – stardust 2013-05-07 10:36:31
很多事情都是错误的,我甚至从哪里开始?你有一个函数,听起来像一条指令去做某件事,但然后返回一些东西。你使用qsort。你投了一个函数指针。你不明白指针,引用和值之间的区别。你有一个指针向量,你也会返回一个(或者甚至是一个指向向量指针的指针),这从所有权角度来看是完全混淆的。基本上,问题是你不知道C++。为了解决这个问题,我建议你阅读一本好书。 – 2013-05-07 10:36:56
@命名为Vector的所有对象Vector –
Matt
2013-05-07 10:45:23