开发者

What does 'Font(..)' mean when Font is a class?

开发者 https://www.devze.com 2022-12-20 20:19 出处:网络
I need help in understanding the following C++ code (in a .h file): bool setFontDescription(const FontDescription& v)

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

精彩评论

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