class X
{
public:
  X() {}
  void destroy() const { delete this; }
protected:
  ~X() {}
};

class Y : public X { };    // inheritance is ok
class Z { X x; };          // syntax error, use pointer


X x1;                      // syntax error
int main()
{
    X x2;                  // syntax error
    Y y1;                  // ok, would be syntax error if ~X() was private
    X* xp = new X;         // ok
    Y* yp = new Y;         // ok

    delete xp;             // syntax error
    xp->destroy();         // ok
    delete yp;             // ok, would be syntax error if ~X() was private
};