开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜