Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
鉴于声明
class DBuffer { //... }; typedef QList<DBuffer*> DBuffers; QList<int> fds; QMap<int, DBuffers> buffers;
下面给出的函数中的代码行是什么意思。
function() { // what does this line mean? what is "&bufs" DBuffers &bufs=buffers[fds[i]]; }
声明中的 & 表示该变量是一个引用,即 bufs 不会创建输出的新副本,而只是引用分配给它的对象。在这种情况下,引用类型可以被认为是分配给它们的对象的别名。
表达式的 RHS 非常简单:通过索引 i 从 fds 列表中查找一个整数,然后使用该值从映射中获取相应的 Dbuffer。
是参考。这意味着您从buffer. 别名的变化也反映在缓冲区的项目中
buffer