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



Question:

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->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?


Solution:1

Create a Font object on stack, as a temporary. The object's scope is the line where it's created.


Solution:2

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »