0

A Template Version of List Class

can be like this:

template <class T> class List;

template <class W>
class Node {
        friend class List<W>;
        private:
                W data;
                Node *next;
        public:
                Node();
                Node(const W &data);
                Node(const W &data, Node *nxt);
                Node &operator=(const Node &n);
                virtual ~Node();
};

template <class T>
class List {
private:
        int count;
        int out_of_memory;
        Node<T> *head;
        void Copy(const List &lst);
        void initList();
        void deInitList();
public:
        List();
        List(const List &lst);
        List(const T &data);
        virtual ~List();
        List &operator=(const List &lst);
        bool isEmpty();
        bool isFull();
        int deleteFromHead(T &t);
        int deleteFromList(const T &t);
        int add(const T &t);
        int addToTail(const T &t);
};

0

Ken Thompson on C++

In an interview for Coders at Work book:

It certainly has its good points. But by and large I think it’s a bad language. It does a lot of things half well and it’s just a garbage heap of ideas that are mutually exclusive. Everybody I know, whether it’s personal or corporate, selects a subset and these subsets are different. So it’s not a good language to transport an algorithm—to say, “I wrote it; here, take it.” It’s way too big, way too complex. And it’s obviously built by a committee.

Stroustrup campaigned for years and years and years, way beyond any sort of technical contributions he made to the language, to get it adopted and used. And he sort of ran all the standards committees with a whip and a chair. And he said “no” to no one. He put every feature in that language that ever existed. It wasn’t cleanly designed—it was just the union of everything that came along. And I think it suffered drastically from that.

Most of the interviewees mentioned there, apparently did not like C++ for its complexity.

0

Copying a List

This is what I came up with, as one of the member functions of a list class:

class chList {
private:
        chNode *head;
        int count;
        void deleteList(void);
        void initList(void);
        void copyList(const chList &list);

public:
        chList();
        chList(const char &data);
        chList(const chList &list);
        chList &operator=(const chList &list);
        int addToList(const char &data);
        int addToTail(const char &data);
        struct chNode *deleteFromList(const char &data);
        void printList(void);
        bool isEmpty(void);
        ~chList();
};

void chList::copyList(const chList &list)
{
        int i = 1;
        struct chNode *tmp1, *tmp2, *tmp3;

        if (!list.count)
                return;

        tmp2 = list.head;
        while (i <= list.count) {
                tmp1 = new chNode(tmp2->data);
                if (!head) {
                        head = tmp1;
                        tmp3 = head;
                }
                else {
                        tmp3->next = tmp1;
                        tmp3 = tmp1;
                }

                tmp2 = tmp2->next;
                i++;
        }
}

It so happens that if we choose to maintain a count variable, things get a little bit easier.

0

What is Marketing?

From Chris Anderson in his series “Ten Rules for Maker Businesses

Community management is marketing. Tutorial posts are marketing. Facebook updates are marketing. Emailing other Makers in related fields is marketing. I suppose what I’m doing right now, writing this list, is marketing.

The ten part series is very well worth a read, BTW. A good overview/introduction of running/making a business.