Question: I'm trying to create a comment tree but I don't have any idea how to do that. The package I found on `pub.dev` is not like what I want. I mesh with codes. No tutorial found related to me.

This is what I want :

[![Image](https://i.stack.imgur.com/RajQh.jpg)](https://i.stack.imgur.com/RajQh.jpg)

I want a tutorial or idea to create design like showing in the image.

Answer: 
Welcome to stackoverflow and C++!

I tool the liberty of fixing some smaller issues with the code:

`<cmath>` is the proper C++ header, use that instead of `<math.h>` (the C header. C and C++ are different).

Do not build an early habit of `using namespace std`. Yes, it seems convenient, but [read here why you should not do it.](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice)

Using `std::endl` will likely drop your performance. [Read here about the differences](https://stackoverflow.com/questions/213907/stdendl-vs-n). using `\n` works just as good, is cross-platform-compatible and even less to type.

Does this achieve what you want?

```
#include <cmath>
#include <iostream>
#include <string>

class People{
public:
    std::string name;
    int age;
    bool educated;
    People(){
        std::cout << typeid(*this).name() << "class people is initialised\n";
    }
    ~People(){
        std::cout << typeid(*this).name()  << "class people is destroyed\n";
    }
private:
    double worth;
};

int main(){
    People Joe;
}

```

Responding to the comment:

```
People(std::string const& str)
: name(str)
{
        std::cout << name << " class people is initialised\n";

}

////

int main(){
    Person Joe("Joe");
}

```

Note this important difference:
`People(std::string str)` will create a copy of the string (which is usually expensive).

`People(std::string const& str)` will create a constant reference. Constant means it can not be changed and since it is a reference, it will not be copied here (it will be copied into the class member though).
You can use the preprocessor to get the name like this: `typeid(*this).name()`.

P.S. Don't use `using namespace std`. It can make your code unclear.