How-to return a const std::vector<Object *const>?
问题 I have a class with a container (containing pointer) as a member: MyClass{ private: std::vector<MyObject*> _VecMyObjs; public: const std::vector<MyObject* const> GetVecMyObj(); } Now I try to implement GetVecMyObj(). Here is what I came up with... const vector<MyObject *const> ACI_CALL MyClass::GetVecMyObjs() { const vector<MyObject *const> VecMyObjs; VecMyObjs.assign( _VecMyObjs.begin(), _VecMyObjs.end()); return VecMyObjs; } But of course the compiler is warning me, that I use the assign