Believe it or not, it's not possible in C++ before version 17 (inline).
But you can simulate it (I think, this should have had worked even in the first versions C++).
Proud to present a new article on my homepage ([at least] currently only available in English):
http://peter-sulzer.bplaced.net/htdocs/index.php?pagefile=develop/cpp/classVarsWithInit.hti (WARNING: Link opens in SAME Window/Tab, albeit linking to another site!)
C++ Initialised Static (Class) Variables with Source and Explanation
C++ Initialised Static (Class) Variables with Source and Explanation
http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
- NormanDunbar
- Forum Moderator
- Posts: 2281
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: C++ Initialised Static (Class) Variables with Source and Explanation
I'm getting a 404 page when I follow that link.ql_freak wrote: ↑Thu Jan 11, 2024 1:19 am
Proud to present a new article on my homepage ([at least] currently only available in English):
http://peter-sulzer.bplaced.net/htdocs/index.php?pagefile=develop/cpp/classVarsWithInit.hti (WARNING: Link opens in SAME Window/Tab, albeit linking to another site!)
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
-
- Font of All Knowledge
- Posts: 3997
- Joined: Mon Dec 20, 2010 11:40 am
- Location: Sunny Runcorn, Cheshire, UK
Re: C++ Initialised Static (Class) Variables with Source and Explanation
Step closer to C++ for the QL!
Regards,
Derek
Derek
Re: C++ Initialised Static (Class) Variables with Source and Explanation
Oops, I have thought, I have had answered this problem. Please try:
Code: Select all
http://peter-sulzer.bplaced.net/htdocs/index.php?pagefile=develop/cpp/classVarsWithInit.hti
C++ Class Variables
(There is a British flag before the menu entry)
Sincerely
Peter
http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
Re: C++ Initialised Static (Class) Variables with Source and Explanation
This may be a non-problem for modern C++ (if this can be handled at all in a QL forum), because these days singletons have become highly out-of-fashion (Mainly for the reason that they are just global variables in disguise, with all their downsides).
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
- NormanDunbar
- Forum Moderator
- Posts: 2281
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: C++ Initialised Static (Class) Variables with Source and Explanation
Hi Peter,
it is indeed fixed on the original URL. Thanks.
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.