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
Post a Comment