排序函数中的C ++错误

时间:2015-10-22 13:34:46

标签: c++

我正在为作业制作学生记录系统。尝试运行程序时,我收到错误:

  

“错误:从''转换为非标量类型'std :: stringstream'请求”

它来自HList行。不确定有什么问题。

stringstream key = student[j].getLastName

1 个答案:

答案 0 :(得分:1)

执行stringstream key = student[j].getLastName时,您尝试创建从stringstream复制的新getLastName对象。现在,getLastName可能是一个成员函数,因此编译器不知道如何从中构建stringstream

你可能想要从你的成员函数初始化一个stringstream并返回,所以:

stringstream key(student[j].getLastName());