C++ access to static class member variables, not friend -


i'm sorry in advance if stupid or nonsense question, but:

can non-constant static class variable 1 class used class without using friend or base/derived classes? (abbreviated) situation is:

class decl {     public:           static string searchval;           ... (other irrelevant stuff) };  class conj {     public:         static string searchval;         ... (other irrelevant stuff) }; 

i don't want repeat searchval in both classes, , because of rest of program, i'm not keen on using friend (but if it's option).

since static members public, if class definitions both visible, static members can accessed using decl::searchval or conj::searchval respectively.

for example

class decl  {      public: static string searchval; };  class conj {     public:         static string searchval; };  // within function, including members of either class above //    ... long both definitions above visible compiler   if (conj::searchval == decl::searchval)  {        //  }   

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -