What bugs me are the static const float declarations. First, even though they are in the class header file, they are not part of the class declaration. My first serious introduction to programming was VB.NET and C# and I am still confused with things being declared outside of classes. How is their scope defined? And what does the keyword static mean in this place?
Impossible to understand how Microsoft is thinking this is viable in context of the market, especially Apple. They just want to POSITION themselves at the ultra premium, but it doesn't make sense.
people are using threads? I dont know of a single person that I knew that signed up when it launched that still uses it, is this including "facebook integration" in the count?...
Question
Andre S. Veteran
I was reading the Head First Design Patterns Silver C++ translation and came across this:
#ifndef _HFDP_CPP_VISITOR_INGREDIENT_HPP_ #define _HFDP_CPP_VISITOR_INGREDIENT_HPP_ namespace HeadFirstDesignPatterns { namespace Visitor { namespace Menus { // recommended daily values static const float dailyCalories = 2000.0f; static const float dailyCarbs = 300.f; static const float dailyCholesterol = 0.300f; static const float dailyFat = 65.0f; static const float dailyProtien = 50.0f; static const float dailySodium = 2.400f; class Visitor; class Ingredient : MenuComponent { protected: float _amount; protected: Ingredient( float amount = 1.0f ) : _amount( amount ) { assert( amount > 0.0f ); } public: virtual ~Ingredient() = 0 { } public: virtual void add( MenuComponent* menuComponent ) { } public: virtual void accept( Visitor* visitor ) = 0; public: virtual bool isVegetarian() const = 0; public: virtual float getCalories() const = 0; public: virtual float getCarbs() const = 0; public: virtual float getCholesterol() const = 0; public: virtual float getFat() const = 0; public: virtual float getProtien() const = 0; public: virtual float getSodium() const = 0; public: virtual float getHealthRating() const { float result = 0.0f; result += getCalories() / dailyCalories; result += getCarbs() / dailyCarbs; result += getCholesterol() / dailyCholesterol; result += getProtien() / dailyProtien; result += getSodium() / dailySodium; return _amount * ( result * 100.0f ); } public: virtual std::string toString() const = 0; }; } // namespace Menus } // namespace Vistor } // namespace HeadFirstDesignPatterns #endifWhat bugs me are the static const float declarations. First, even though they are in the class header file, they are not part of the class declaration. My first serious introduction to programming was VB.NET and C# and I am still confused with things being declared outside of classes. How is their scope defined? And what does the keyword static mean in this place?
Thanks.
Link to comment
https://www.neowin.net/forum/topic/651152-c-a-meaning-of-static/Share on other sites
10 answers to this question
Recommended Posts