从对象数组中删除重复项
Delete duplicates from an array of objects
我必须从对象数组中删除重复项,但到目前为止,我的算法给了我错误:
请求'((专辑*)this)中的成员"author"->专辑::歌曲,
指针类型为"Song*"(也许您打算使用"->"?)|
这就是代码:
void Album::deleteDuplicates()
{
Song* current , *end = songs + top - 1;
for ( current = songs + 1; songs < end; songs++, current = songs + 1 )
{
while ( current <= end )
{
if ( current->author == songs.author && current->title == *songs.title
&& current->year == *songs.year && current->length == *songs.length)
{
*current = *end--;
}
else
{
current++;
}
}
}
}
有什么办法吗?
使用以下代码,编译器错误应该会消失。
if ( current->author == songs->author && current->title == songs->title
^^^ ^^^
&& current->year == songs->year && current->length == songs->length)
^^^ ^^^
相关文章:
- 迭代时从向量和内存中删除对象
- C++从对象自己的类中删除对象
- 如何通过对象的类属性删除对象,并返回其对象值?
- 删除对象(具有不同类型)的引用时会发生什么情况?
- 从列表C++中删除对象
- c++ 循环访问对象列表并删除对象
- 从对象本身的容器中删除对象
- 从尝试引用已删除函数的矢量 C++ 中删除对象
- 如何通过指向元组的共享指针删除对象
- 防止通过接口删除对象
- 在 c++ 中从内存中删除对象
- 当对象被删除时,复制被删除对象的对象如何
- 当我使用dynamic_cast并删除对象删除时,析构函数是如何工作的?
- 从内存中删除对象
- 通过C++中的删除方法自行删除对象
- C++ - 析构函数只是释放内存还是实际删除对象
- 如何通过存储在 std::list 中的指针删除对象?
- 如何通过对象参数从指针矢量中删除对象和指针
- 我可以删除对象的右值版本的函数吗?
- 使用对象的索引从矢量中删除对象