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

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

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -