前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >c++ 结构体容器(vector)类型初始化及结构体vector指针传递

c++ 结构体容器(vector)类型初始化及结构体vector指针传递

作者头像
玖柒的小窝
修改2021-09-15 11:39:18
修改2021-09-15 11:39:18
3.1K0
举报
文章被收录于专栏:各类技术文章~
代码语言:c
复制
 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <vector>
 4 
 5 
 6 struct BoxInfo
 7 {
 8     int label;
 9     float score;
10 };
11 
12 
13 int bbox_init(std::vector<BoxInfo> &bboxs)
14 {
15     BoxInfo u_temp;
16     for(int i = 0; i < 10; i++)
17     {
18         u_temp.score = 0.8f +0.1f*i;
19         u_temp.label = i;
20 
21         bboxs.push_back(u_temp);
22     }
23 
24     return 0;
25 }
26 
27 
28 int main()
29 {
30     printf("begin \r\n");
31     std::vector<BoxInfo> bboxs;
32 
33     bbox_init(bboxs);
34 
35     printf("mid \r\n");
36 
37     for(int i = 0; i < 10; i++)
38     {
39         printf("bboxs[%d].score = %f \r\n",i,bboxs[i].score);
40         printf("bboxs[%d].label = %d \r\n",i,bboxs[i].label);
41     }
42     printf("bboxs.size() = %d \r\n",bboxs.size());
43 }

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档