#include <iostream>
#include <string>
int main()
{
std::string s;
s._Mysize = 7; // Well compiled !!!
std::cout << s.size() << '\n'; // prints 7 !!!
}
Why non-static members of the std::basic_string
are public in VS2010 ?
Is this bug ? If yes, how about of next version of visual studio's ( vs2012 and vs2013) ?
EDIT: I just test other containers, and ... interesting vector and unique_ptr's non-static members are public, also.
std::vector<char> v;
v._Myfirst = (char*)2; // Well Compiled.
std::unique_ptr< int > u;
u._Myptr = 0; // well compiled.
Q: Is here any reason or advantage of using public
data members ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With