Basic Stack in C++ Using Array I  wrote a stack class in C++ using arrays of fixed width. Could anyone review my code ? I didn't comment on any of the functions, because I thought class itself is self explanatory. Is it a wrong approach or which kind of comments can I write?

#include &lt;stdlib.h&gt;
#include &lt;iostream&gt;

template &lt;class T&gt;
class Stack {
  public:
    Stack(void);    //ctor
    void push(const T&amp; item);
    T pop(void);
    void clear(void);
    T top(void) const;
    bool empty(void) const;
    bool full(void) const;
    void print(void) const;
  private:
    static const int MAX = 50;
    T list[MAX];
    int topPtr;
};

template &lt;class T&gt;
Stack&lt;T&gt;::Stack(void) {
    this-&gt;topPtr = -1;
}

template &lt;class T&gt;
void Stack&lt;T&gt;::push(const T&amp; item) {

    if(this-&gt;topPtr == this-&gt;MAX - 1) {
        std::cerr &lt;&lt; "Stack overflow. Can't push" &lt;&lt; '\n';
    } else {
        this-&gt;topPtr += 1;
        this-&gt;list[topPtr] = item;
    }
}

template &lt;class T&gt;
T Stack&lt;T&gt;::pop(void) {
    if(this-&gt;topPtr &lt; 0) {
        std::cerr &lt;&lt; "Stack is empty. Can't pop" &lt;&lt; '\n';
    } else {
        T r_value = this-&gt;list[this-&gt;topPtr];
        this-&gt;topPtr -= 1;
        return r_value;
    }
}

template &lt;class T&gt;
void Stack&lt;T&gt;::clear(void) {
    this-&gt;topPtr = -1;
}

template &lt;class T&gt;
T Stack&lt;T&gt;::top(void)const {
    if(this-&gt;topPtr &lt; 0) {
        std::cerr &lt;&lt; "Stack is empty. No top element." &lt;&lt; '\n';
    } else {
        return this-&gt;list[topPtr];
    }
}

template &lt;class T&gt;
bool Stack&lt;T&gt;::empty(void) const {
    return (this-&gt;topPtr == -1);
}

template &lt;class T&gt;
bool Stack&lt;T&gt;::full(void) const {
    return (this-&gt;topPtr == this-&gt;MAX -1);
}

template &lt;class T&gt;
void Stack&lt;T&gt;::print(void) const {
    for (int i = this-&gt;topPtr; i &gt;= 0; i--)
        std::cout &lt;&lt; this-&gt;list[i] &lt;&lt; '\n';
}

```
Seems like a nice implementation! Here are my thoughts,


this is implicit. Consider removing this, i.e. use topPtr instead of this-&gt;topPtr. Similarly, void doesn't need to be used as an argument, consider removing void, i.e. top() instead of top(void).
Consider using std::size_t for MAX. Also, consider naming MAX as MAX_SIZE since it is slightly more descriptive. If using std::size_t, make sure not to subtract one from MAX to avoid overflow. Instead, when checking for equality, add one to the other side. 
It might be nicer to use a T* instead of an int for topPtr. nullptr could be used instead of -1 initially for topPtr.
For print consider passing a std::ostream object. This allows for decoupling and one could pass in a std::ostringstream instead of std::cout if desired.
For top and pop, consider using assert instead if/else. An exception could also be used, but I think assert is a little nicer. To include a message, use something similar assert(!empty() &amp;&amp; "Stack is empty. Can't pop");. See https://en.cppreference.com/w/cpp/error/assert. Maybe add a comment about the requirements of these functions.
Consider adding documentation for any public function. Include information such as what the function returns, requires, and modifies. For example, top requires there are element in the stack.