fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5. class classe
  6. {
  7. public:
  8. int var;
  9. vector<int> vetint;
  10. };
  11.  
  12.  
  13. int main()
  14. {
  15. vector<classe> vetor;
  16. classe obj;
  17.  
  18. for (unsigned i=0; i<2 ; i++) {
  19. obj.var = (i+1)*10;
  20. for (unsigned c=0; c<3 ; c++) {
  21. obj.vetint.push_back((c+1)*100);
  22. }
  23. vetor.push_back(obj);
  24. }
  25. for (unsigned i=0; i < vetor.size() ; i++) {
  26. cout << "var(" << i << ") = " << vetor[i].var << endl;
  27. for (unsigned c=0; c < vetor[i].vetint.size() ; c++) {
  28. cout << "vetint(" << c << ") = " << vetor[i].vetint[c] << endl;;
  29. }
  30. }
  31. }
  32.  
Success #stdin #stdout 0s 4360KB
stdin
Standard input is empty
stdout
var(0) = 10
vetint(0) = 100
vetint(1) = 200
vetint(2) = 300
var(1) = 20
vetint(0) = 100
vetint(1) = 200
vetint(2) = 300
vetint(3) = 100
vetint(4) = 200
vetint(5) = 300