#include <iostream>
using namespace std;

class List
{
    struct Node
    {
        int data;
        Node *next = nullptr;

        Node(int data1) : data(data1) { }
    };

    Node *head, *tail;

public:
    List() : head(nullptr), tail(nullptr) { }
    List(const List&) = delete;
    List& operator=(const List&) = delete;

    ~List()
    {
        Node *n = head;
        while (n)
        {
            Node *next = n->next;
            delete n;
            n = next; 
        }
    }

    void push_back(int data)
    {
        Node **n = (tail) ? &(tail->next) : &head;
        *n = new Node(data);
        tail = *n;
    }

    friend ostream& operator<<(ostream &os, const List &list)
    {
        Node *n = list.head;
        if (n)
        {
            os << n->data;
            while (n = n->next)
            {
                os << ',' << n->data;
            }
        }
        return os;
    }
};

int main()
{
    int arr[] = {1, 2, 3, 4, 5, 6};
    List list;
    for(int elem : arr)
        list.push_back(elem);
    cout << list;
    return 0;
}