I was learning stl and never saw this kind of class like class classname :: reference {}
I searched on the net but could get good information ..
class bitset::reference {
friend class bitset;
reference(); // no public constructor
public:
~reference();
operator bool () const; // convert to bool
reference& operator= ( bool x ); // assign from bool
reference& operator= ( const reference& x ); // assign from bit
reference& flip(); // flip bit value
bool operator~() const; // return inverse value
};
- what is this :: reference here for ?
i saw this code here[enter link description here][1]
http://www.cplusplus.com/reference/stl/bitset/
i have worked on c++ before.
Did you look at the bitset class definition? There is something like this somewhere:
It’s much like putting the body of a funciton outside the class body. Now we are putting the body of a nested class outside of the parent class:
By the way, in MSVC (
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\bitset) the’re actually defined inside each other:It’s the same for g++’s
bitset.h, although a bit more complex.