C++ (Qt)#include <QSize>struct MyStruct{ int width() const; static constexpr QSize size{20, 20};}; int MyStruct::width() const{ return size.width();} int main(){ MyStruct().width(); return 0;}
int MyStruct::width() const{ return MyStruct::size.width();}
C++ (Qt)class Size { double w,h;public: constexpr Size(double w, double h) : w(w), h(h){} constexpr double width() const{ return w; } constexpr double height() const{ return h; }}; struct MyStruct{ int width() const; static constexpr Size size{20, 20};}; int MyStruct::width() const{ return size.width();} int main(void) { MyStruct().width(); return 0;}
C++ (Qt)struct MyStruct{ int width() const; constexpr Size size() const { return Size(20, 20); }};
C++ (Qt)class Size { double w,h;public: constexpr Size(double w, double h) : w(w), h(h){} constexpr double width() const{ return w; } constexpr double height() const{ return h; }}; struct MyStruct{ int width() const; constexpr Size size() const { return Size(20, 20); }}; int MyStruct::width() const{ return size().width();} int main(void) { return MyStruct().width();}
ASMMyStruct::width() const: mov eax, 20 retmain: mov eax, 20 ret
C++ (Qt)struct MyStruct{ constexpr double width() const { return size().width(); } constexpr Size size() const { return Size(20, 20); }};
C++ (Qt)class Size { double w,h;public: constexpr Size(double w, double h) noexcept : w(w), h(h){} constexpr double width() const noexcept{ return w; } constexpr double height() const noexcept{ return h; }}; struct MyStruct{ constexpr int width() const noexcept; static const Size size;};constexpr Size MyStruct::size{20, 20}; constexpr int MyStruct::width() const noexcept{ return size.width();} int main() { constexpr int w = MyStruct().width(); return 0;}