错误:在类方法声明中无效地使用void表达式
error: Invalid use of void expression , in a class method declaration
事情是这样的。我试图建立一个EditorBuffer类(单行文本编辑)。
类由两个字符堆栈(stack<char> before , stack<char> after)
组成,其中前堆栈表示位于"光标"之前的所有字符,后堆栈表示位于"光标"之后的所有字符。在下面的声明中,我得到了错误error: Invalid use of void expression
,这对我来说是完全陌生的。
方法声明:
void EditorBuffer::moveCursorToEnd()
{
while (!after.empty())
{
before.push(after.pop());
}
}
std::stack::pop()
不返回任何东西(它的返回类型是void
)。你可能想这样做:
before.push(after.top());
after.pop();
相关文章:
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- (C++)分析树以计算返回错误值的简单算术表达式
- void() 是一个有效的C++表达式吗?
- 为什么新表达式可以正确生成指针类型,即使它应该返回 void*?
- 在c++std::函数的上下文中无效使用void表达式
- 无效地将 void 表达式与队列和 .pop() 一起使用
- 代数树表达式C++错误:未解析的外部符号"Public:_thiscall AlgebraicTreeExpression::~AlgebraicTreeExpression(void) ..."
- 使用多线程处理对象数组 - 无效使用 void 表达式错误
- 您可以在表达式中使用 void 返回函数吗?
- C STD ::线程无效的void表达式使用
- static_casting constexpr void* 的结果是常量表达式吗?
- 错误:无效使用了void表达式C++
- LAMBDA 错误:类型 'void' 的条件表达式是非法的
- lambda表达式中出现无效的使用Void表达式错误
- 错误:在类方法声明中无效地使用void表达式
- c++ 14是否要求delete表达式必须调用' void operator::delete(void*, std::
- 无法在VS 14 CTP中使用auto声明lambda:类型为'void'的条件表达式是非法的
- 无效地将void表达式与线程和对象一起使用
- 编译错误:无效使用了void表达式
- 可变模板:无效使用void表达式