精品国产免费久久久,日韩美精品成人一区二区三区四区,米奇7777无码一区,天天综合色天天综合色,国产欧美色一区二区三区,99久久99久久免费精品,欧美黄色一级视频,国产成在线观看免费视频

歡迎來到 常識詞典網 , 一個專業的常識知識學習網站!

[ Ctrl + D 鍵 ]收藏本站

您所在的位置:首頁 > 教育學習 > 知道

知道

C++中vector元素的類型為指針,如何將其賦為NULL?

分類: 知道 常識詞典 編輯 : 常識 發布 : 04-24

閱讀 :572

C++中vector元素的類型為指針,如何將其賦為NULL?vector<int*> p(5, NULL); 這段代碼能被最新的g++編譯,但在某些老版本的g++中,會給出如下錯誤信息: warning: passing NULL to non-pointer argument 2 of "std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [wit- _InputIterator = int, _Tp = int*, _Alloc = std::allocator<int*>, allocator_type = std::allocator<int*>]"In file included from /usr/include/c++/4.5/vector:65:0, ……1 個答案

答案 1:

null 是const int,與int* 指針類型不符合 轉一下就可以了: std::vector<int*> v1(5,static_cast<int*>(0));

下一篇:投資入門需要些什么? 下一篇 【方向鍵 ( → )下一篇】

上一篇:大家現在用什么瀏覽器?。縄E用戶還很多嗎? 上一篇 【方向鍵 ( ← )上一篇】