[spam][crazy] coding therapy: hello world with structure
Undescribed Horrific Abuse, One Victim & Survivor of Many
gmkarl at gmail.com
Thu Oct 13 17:27:28 PDT 2022
class HelloWorldNode {
public:
HelloWorldNode(HelloWorldNode * parent, string data)
: parent(parent),
data(data)
{
if (parent)
parent.children.add(this);
}
~HelloWorldNode()
{
if (parent)
parent.children.erase(this);
}
void print() {
cout << data;
for (auto child : children)
child.print();
}
private:
HelloWorldNode * parent;
string data;
set<HelloWorldNode*> children;
};
using HWN = HelloWorldNode;
int main() {
HWN hello(0, “hello”);
HWN space(&hello, “ “);
HWN world(&space, “world”);
HWN bang(&world, “!”);
HWN decorations[] = {
HWN(&hello, “\t”),
HWN(&world, “~~”),
HWN(&bang, “#”)
};
hello.print();
}
More information about the cypherpunks
mailing list