Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have to write a C++ program thatcreates a stack of POINTs for up to 100 points

ID: 3617030 • Letter: I

Question

I have to write a C++ program thatcreates a stack of POINTs for up to 100 points, see class POINTfollowed by stack class below respectively. Basically I am facingtrouble passing a point instead of item in my class Stack's pushmethod
class POINT
{
    private:
      int x, y;
    public:
      POINT(int a, int b)
        { x = a; y = b;}
};
The class for stack is as follows:
template <classItem>
class STACK
{
    private:
      Item *s; int N;
    public:
      STACK(int maxN)
        { s = new Item[maxN]; N= 0; }
      int empty() const
        { return N == 0; }
      void push(Item item)
        { s[N++] = item; }
      Item pop()
        { return s[--N]; }
      void flush()
      { /* implement this part */
      }
};


I have to write a C++ program thatcreates a stack of POINTs for up to 100 points, see class POINTfollowed by stack class below respectively. Basically I am facingtrouble passing a point instead of item in my class Stack's pushmethod
class POINT
{
    private:
      int x, y;
    public:
      POINT(int a, int b)
        { x = a; y = b;}
};
The class for stack is as follows:
template <classItem>
class STACK
{
    private:
      Item *s; int N;
    public:
      STACK(int maxN)
        { s = new Item[maxN]; N= 0; }
      int empty() const
        { return N == 0; }
      void push(Item item)
        { s[N++] = item; }
      Item pop()
        { return s[--N]; }
      void flush()
      { /* implement this part */
      }
};


Explanation / Answer

#include<iostrem>
using namespace std;

class POINT
{
    private:
      int x, y;
    public:
      POINT(int a, int b)
        { x = a; y = b;}
  int getX()
  {
   return x;
  }
  int getY()
  {
   return y;
  }
  void setX(int xval)
  {
   x=xval;
  }
  void setY(int yval)
  {
   y=yval;
  }

};