Question

In: Computer Science

Class object in C++ programming language description about lesson static variable example.

Class object in C++ programming language description about lesson static variable example.

Solutions

Expert Solution

#include

 

using namespace std;

class product{

  private:

    static float price,total;

    float qty, amount;

  public:

    product(const product&);

    product(float = 0);

    static float getprice();

    static float gettotat();

    static float getamount();

    void setprice(float pr);

    int equal();

    void input();

    void print();

};

 

float product::price=2000;

float product::total=0;

 

product::product(const product &qty){

  this->qty=qty.qty;

  this->amount=qty.amount;

  total+=this->amount;

}

float product::product(float qty)

:qty(qty)

{

  amount=qty*price;

  total+=amount;

}

int product::equal(product other){

  if(this->qty==other.qty && this->amount==other.amount)

    return 1;

  else

    return 0;

}

float product::getamount(){

  return amount;

}

float product::getprice(){

  return price;

}

float product::gettotat(){

  return total;

}

product::setprice(3800){

  return price;

}

int main(){

  product p1(2),p2(3);

  p1

  

}


Related Solutions

Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson Overloading function example.
Class object in C++ programming language description about lesson Overloading function example.
Class object in C++ programming language description about lesson copy constructor example.
Class object in C++ programming language description about lesson copy constructor example.
Class object in C++ programming language description about lesson base class and derived class example.
Class object in C++ programming language description about lesson base class and derived class example.
Class object in C++ programming language description about lesson inheritance multi level example.
Class object in C++ programming language description about lesson inheritance multi level example.
Class object in C++ programming language description about lesson unary overloading function example.
Class object in C++ programming language description about lesson unary overloading function example.
Code in C++ programming language description about chose favorite fruit and wage color of fruit in lesson Class object (Multiple class).
Code in C++ programming language description about chose favorite fruit and wage  color of fruit in lesson Class object (Multiple class).
Code in C++ programming language description about lesson Calculator (multiple, sum, dived, sub) example.
Code in C++ programming language description about lesson Calculator (multiple, sum, dived,  sub) example.
Code in C++ programming language description about read and write data to memory example.
Code in C++ programming language description about read and write data to memory example.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT