Super Market

#include <iostream>
using namespace std;
class consumer
{
  public:
  virtual void getdata()=0;
  virtual void display()=0;
};

class transaction:public consumer
{
public:
    int c,q,p,tp;
    long t;
    char n[100];
    void getdata()
    {
    cin>>n>>c>>t>>q>>p>>tp;
    }
    void display()
    {
    cout<<"Name : "<<n<<endl;
        cout<<"Code : "<<c<<endl;
        cout<<"Telephone : "<<t<<endl;
        cout<<"Quantity : "<<q<<endl;
        cout<<"Price : "<<p<<endl;
        tp=q*p;
        cout<<"Total Price : "<<tp<<endl;
    }

};

int main()
{
consumer *c;
  transaction t;
  c=&t;
  c->getdata();
  c->display();
return 0;
}

No comments:

Post a Comment