我正在source of streambuf in the gnu online doc中执行render()
。我无法理解为什么在seekpos
行中注释__mode
以及为什么它不会引发错误。
ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out
我可以理解评论的用法,如果它的格式如下:
virtual pos_type
seekpos(pos_type, ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
{
return pos_type(off_type(-1));
}
但是,在前一种情况下,还有意向void foo( pos_type, int /*blah*/ ){
...
}
分配内容,因此我很惊讶没有在那里收到任何错误。
这是允许的吗?如果是,那么为什么?
答案 0 :(得分:5)
首先,它不是作业,而是默认参数。你可以让任何所有参数都是匿名的。
如果函数内部没有使用参数,则可以省略变量名,只需要类型,并且(如上所述)甚至是默认参数。参数变量名称是可选的。