Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class tree {
- public:
- tree() = default;
- tree(int base, const std::string &newCont = "*") { makeTree(base, newCont); }
- friend std::ostream &output(tree &oTree, std::ostream &os);
- void makeTree(int, const std::string&);
- private:
- std::vector<std::string> Tree;
- };
- void tree::makeTree(int newBase, const std::string &newCont = "*") {
- Tree.clear();
- std::string tempString;
- for(int tempbase = 0; tempbase != newBase; ++tempbase) {
- tempString += newCont;
- Tree.push_back(tempString);
- }
- }
- std::ostream &output(tree &oTree, std::ostream &os) {
- for (auto c: oTree.Tree) {
- os << c << '\n';
- }
- return os;
- }
Advertisement
Add Comment
Please, Sign In to add comment