Guest User

Untitled

a guest
Jan 13th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. class tree {
  2. public:
  3.     tree() = default;
  4.     tree(int base, const std::string &newCont = "*") { makeTree(base, newCont); }
  5.     friend std::ostream &output(tree &oTree, std::ostream &os);
  6.     void makeTree(int, const std::string&);
  7. private:
  8.     std::vector<std::string> Tree;
  9. };
  10.  
  11. void tree::makeTree(int newBase, const std::string &newCont = "*") {
  12.     Tree.clear();
  13.     std::string tempString;
  14.     for(int tempbase = 0; tempbase != newBase; ++tempbase) {
  15.         tempString += newCont;
  16.         Tree.push_back(tempString);
  17.     }
  18. }
  19.  
  20. std::ostream &output(tree &oTree, std::ostream &os) {
  21.     for (auto c: oTree.Tree) {
  22.         os << c << '\n';
  23.     }
  24.     return os;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment