Write a program to perform Pointer on class Box

/*
    Class Box using Pointer
*/
#include<iostream>
using namespace std;

class Box
{
   int height,width,breadth;

   public:
          void accept(int height,int width,int breadth)
          {
            this->height=height;
            this->width=width;
            this->breadth=breadth;
          }

          void display()
          {
            cout<<"\n\n Height: "<<height;
            cout<<"\n Width: "<<width;
            cout<<"\n Breadth: "<<breadth;
          }
};

int main()
{
    Box B,*BP=&B;

    BP->accept(10,20,30);
    B.display();

    return 0;
}

Previous
Next Post »