草庐IT

IncomingLanes

全部标签

c++ - 在以下 C++ 语句中放置 const 的好地方是什么

考虑以下类成员:std::vectorIncomingLanes_;上面的容器应该存放一些ifmy里的对象的指针。我不希望使用此变量作为参数的子程序能够修改Lane对象。同时,我不知道将不会阻止我填充容器的“const”关键字放在哪里。你能帮我解决这个问题吗?谢谢你和问候瓦赫德编辑:根据我到目前为止得到的答案(非常感谢他们所有人)假设这个样本:#include#includeusingnamespacestd;classLane{private:inta;public:Lane(inth):a(h){}voidsetA(inta_){a=a_;}voidprintLane(){std: