visual c++ - C++ Access Control -
this question has reply here:
what access specifiers? should inherit private, protected or public? 2 answersi want define within class variable can read other function can modified fellow member function. example, c# has property purpose. traditionally, we've defined function returns private fellow member variable. think not sophisticated.
is there other way in c++?
class { private: string m_string; public: const string& getstring() const { homecoming m_string; } __declspec(property(get=getstring)) string string; }; a; cout << a.string << endl;
still not in c#, though.
and of course of study there's c++/cli properties (for managed classes), closer c# properties:
ref class { private: string^ m_thestring; public: property string^ thestring { string^ get() { homecoming m_thestring; } } };
c++ visual-c++
No comments:
Post a Comment