[C++程序设计语言] {"key":[1,2,3]}这种map容器是没法构造的吧?

发信人: legendjack (legendjack), 信区: CPlusPlus
标 题: {"key":[1,2,3]}这种map容器是没法构造的吧?
发信站: 水木社区 (Fri Apr 27 15:28:03 2018), 站内

2)使用数组指针(需要注意局部变量的问题,指针是否需要用new创建)

int red [ 3 ] = { 1 , 0 , 0 };
int green [ 3 ] = { 0 , 1 , 0 };
int blue [ 3 ] = { 0 , 0 , 1 };
std :: map < int , int (*)[ 3 ]> colours ;
colours . insert ( std :: pair < int , int (*)[ 3 ]>(( GLUT_LEFT_BUTTON ,& red ));
colours . insert ( std :: pair < int , int (*)[ 3 ]>(( GLUT_MIDDLE_BUTTON ,& blue ));
colours . insert ( std :: pair < int , int (*)[ 3 ]>(( GLUT_RIGHT_BUTTON ,& green ));
//Watch out for scope here, you may need to create the arrays on the heap.

https://ift.tt/2FkocWB
被这篇文章误导了,试过没法编译通过
--

※ 来源:·水木社区 http://www.newsmth.net·[FROM: 218.30.113.*]



from 水木社区 电脑技术区十大热门话题 https://ift.tt/2I1HKSp
via IFTTT

评论

此博客中的热门博文

丰田将在 2019 东京车展上展出一台超迷你的都市型电动车

[数字家庭] [原创]北京联通IPTV的完美方案

英特尔将推出更多支持 e-SIM 的 modem