-2
 LayerVector anotherLayer;
 const LayerVector& currentLayers(anotherLayer);

我不明白为什么在&这里使用参考。

编辑:我的耻辱。我只知道可以通过以下方式定义引用。上面的方式让我感到困惑......谢谢你们!

 const LayerVector &currentLayers = anotherLayer
4

1 回答 1

1

这声明currentLayersconst 引用并将其初始化为anotherLayer. 这实质上意味着 thatcurrentLayers将是anotherLayer. 它是const意味着anotherLayer无法通过此引用更改,只能读取。

于 2012-11-22T09:04:58.047 回答