C++ trying to make shared elements by all objects of a class

  c++, class, static

I would like to pose a question in order to be sure I understood the concept of static. So I have a vector of many objects, but each object has in common 2 values. My class is code is the following

   private: 
            static double EnthalpieInf;
            static double Bernoulli;
            double EnthalpiePUM;
            double Temperature;
            double Pression;
            bool nuage;

public:     void setEnthalpieInf(double Tinf=284.5){
                    EnthalpieInf=(7.0/2.0)*physique::Rmolaire/physique::Mair*Tinf;
                    }
                    
            void setBernoulli(double v0){
                    Bernoulli=pow(v0,2)/2.0+EnthalpieInf;
                }

Thus in the main function in order for those two to be Initialized in a way that they would be used by all objects I have to write:

         cotenu[0][0][0].setEnthalpieInf();

Source: Windows Questions C++

LEAVE A COMMENT