fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. class x {
  5. public:
  6. int var1, var2;
  7. };
  8.  
  9. int main() {
  10. std::vector<x> teste;
  11.  
  12. x obj1; //criar o objeto
  13. obj1.var1 = 10;
  14. obj1.var2 = 20;
  15. teste.push_back(obj1); //adicionar ao vetor
  16.  
  17. std::cout<<teste[0].var1<< " " <<teste[0].var2; //10 20
  18. return 0;
  19. }
Success #stdin #stdout 0s 4496KB
stdin
Standard input is empty
stdout
10 20