fork(1) download
  1. #include <string>
  2. #include <vector>
  3. #include <memory>
  4. using namespace std;
  5.  
  6. class Botao {
  7. private:
  8. string nome;
  9. public:
  10. Botao(string texto) {
  11. nome = texto;
  12. }
  13. };
  14.  
  15. class Caixa {
  16. private:
  17. vector<shared_ptr<Botao>> botoes;
  18. public:
  19. void addBotao(shared_ptr<Botao> botao) {
  20. botoes.push_back(botao);
  21. }
  22. shared_ptr<Botao> getBotao(int i) {
  23. return botoes[i];
  24. }
  25. };
  26.  
  27. int main() {
  28. auto caixa1 = Caixa();
  29. auto botao1 = make_shared<Botao>("clique");
  30. caixa1.addBotao(botao1);
  31. }
  32.  
  33. //https://pt.stackoverflow.com/q/99584/101
Success #stdin #stdout 0s 4276KB
stdin
Standard input is empty
stdout
Standard output is empty