int main() { meta_segment数据; TheData.num.push_back(5.0); //将1个条目添加到num TheData.num.push_back(7.0); //和另一个 for(int i = 0; i< 200; ++ i)//到底是什么... TheData .nu​​m.push_back(i); // ...添加很多它们 } - Karl Heinz Buchegger kb ****** @ gascad.at 你可以使用std :: vector: #include< vector> #include< iostream> struct meta_segment { long double id; std :: vector< long double> num; std :: vector< long double>意思是; 布尔完成; }; int main() { meta_segment seg; seg.num.push_back(12345); seg.num.push_back(54321); std :: cout<< seg.num [1]<< ''\ n''; }You can use std::vector:#include <vector>#include <iostream>struct meta_segment{long double id;std::vector<long double> num;std::vector<long double> mean;bool done;};int main(){meta_segment seg;seg.num.push_back(12345);seg.num.push_back(54321);std::cout << seg.num[1] << ''\n'';} 这篇关于可变长度的结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-25 05:38