Gospel110 2015-05-21 02:09 采纳率: 0%
浏览 1908

小白求助C++问题,在线等

void StudentList::DeleteStudent(string s)
{
vector ::iterator p1;
p1=stuArr.begin();
if (stuArr.size()==0)
{
cout<<"当前列表没有元素可以删除"< }
else
{
while (p1!=stuArr.end())
{
if(p1->GetName()=s)
{
stuArr.erase(p1);
}
}
}
}

编译C:\Documents and Settings\Administrator\桌面\实验9\实验9\StudentList.cpp(27) : error C2451: conditional expression of type 'class std::basic_string,class std::allocator >' is illegal
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.

StudentList.obj - 1 error(s), 0 warning(s)

  • 写回答

10条回答 默认 最新

  • 参观西湖 2015-05-21 02:34
    关注

    cout 末尾多一个<
    if(p1->GetName()=s) 这个是==吧
    if以后,若不等,p1没有指向下一个,while可能是死循环

    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试