Answer to Question #230080 in C++ for mahnoor

Question #230080

Declare Static members as public and Show the behavior change of those members by writing relative member functions.Declare Static members as public and Show the behavior change of those members by writing relative member functions.


1
Expert's answer
2021-08-28T01:35:36-0400
#include <iostream>
using namespace std;


class A {
    private:
      double x1;    
      double y1;  
      double z1;
    public:
      static int count;
      A(double x, double y, double z) {
         x1=x;
         y1=y;
         z1=z;
         count++;
      }
      double Volume() {
         return x1*y1*z1;
      }
      
        
};


int A::count = 0;


int main(void) {
   A a1(1.1, 2.2, 3.3);
   A a2(4.4, 5.5, 6.6);   


   cout << "Number of objects created= " << A::count << endl;


   return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS