Small tree generator If one enters, say, "2, j" then it prints:

j
jj


If there is no second it should be *, so if it's just 2, it's * **.

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;

using std::string; using std::cin; using std::cout; using std::endl; using std::ostream; using std::vector;

class tree {
public:
    friend ostream &amp;output(tree &amp;oTree, ostream &amp;os);
    bool makeTree(int, const string&amp;);
private:
    vector&lt;string&gt; Tree;
};

bool tree::makeTree(int newBase, const string &amp;newCont = "*") {
    if (!Tree.empty())
        Tree.clear();
    string tempString;
    for(int tempbase = 0; tempbase != newBase; ++tempbase) {
        tempString += newCont;
        Tree.push_back(tempString);
    }
  return 1;
}

ostream &amp;output(tree &amp;oTree, ostream &amp;os) {
    for (auto c: oTree.Tree) {
        os &lt;&lt; c &lt;&lt; endl;
    }
    return os;
}


int main() {

}
Don't do this (its not readable).

using std::string; using std::cin; using std::cout; using std::endl; using std::ostream; using std::vector;


One declaration per line.

using std::string;
using std::cin;
using std::cout;
using std::endl;
using std::ostream;
using std::vector;


But actually prefer not to do it at all. If you must do it then confine it to the most narrow scope possible. The whole reason that the standard library is std:: is so that it does not cost much to prefix members by it.

std::cout &lt;&lt; "Hello World" &lt;&lt; std::endl; // Not that hard


It cost nothing to clear an empty tree.

if (!Tree.empty())  // Why do this test. Just call clear.
    Tree.clear();


In C++ the &amp; and * are usually placed with the type (its type information). This is different from C.

bool tree::makeTree(int newBase, const string &amp;newCont = "*") {
                                             ^^^  Looks strange.


// I would write it like this:
// Note: I also put the const the other side (but that's more a personal 
// preference and there is no clear better style there).
bool tree::makeTree(int newBase, string const&amp; newCont = "*") {


Don't use integers to represent bools. At the end of makeTree() I see.

return 1;

// Use a boolean value.
return true;


But there is no failure value so why return anything at all?

Prefer '\n' over std::endl. The difference between the two is that std::endl does an extra flush. This can make using it very inefficient. The whole point of using the buffer is to make printing efficient and the streams are flushed at optimal points automatically and forcing a flush will make the use of stream less optimal.