[Uml-devel] [Bug 60452] missing keywords for declaring operations and variables
Michael Dean
mtdean at hotmail.com
Sun Jul 6 07:03:06 UTC 2003
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=60452
------- Additional Comments From mtdean at hotmail.com 2003-07-06 16:01 -------
Oh, I also forgot the keyword mutable.
(In case anyone is not familiar with the keyword mutable, it's a flag to tell
the compiler the constness of a variable can be cast away)
Ex:
class A
{
public:
mutable int myint;
int notmyint;
};
int main( int argc, char** argv )
{
const A myA;
myA.myint = 5; // **** ERROR **** myint is const because it's containing
// class is const
const_cast<A>(myA).myint = 5; // This compiles fine because its constness
// has been cast away by const_cast<T>()
const_cast<A>(myA).notmyint = 5; // **** ERROR **** will not compile because
// notmyint was not declared mutable
}
I think I've thought of all the neccessary missing keywords now (hopefully).
BTW, http://www.gotw.ca/gotw/006.htm is a great guru article on when to use
const and when to not, if anyone's interested in it. It's by Herb Sutter, good
article.
More information about the umbrello-devel
mailing list