What does 'Font(..)' mean when Font is a class?
I need help in understanding the following C++ code (in a .h file):
bool setFontDescription(const FontDescription& v)
{
if (inherited->font.fontDescription() != v) {
inherited.access()->font = Font(v, inherited开发者_StackOverflow社区->font.letterSpacing(), inherited->font.wordSpacing());
return true;
}
return false;
}
What does 'Font(..)' mean? Font is a C++ class. Does Font(...) mean new Font()? Or create a Font object on the stack?
Create a Font object on stack, as a temporary. The object's scope is the line where it's created.
It means create a Font on the stack, then assign that new Font to the access()->font variable. The Font on the stack is destroyed when that setFontDescription returns destroyed when the assignment is done.
精彩评论