C++ Initialised Static (Class) Variables with Source and Explanation

Tell us about your other hobbies & none QL related items here :)
Post Reply
User avatar
ql_freak
Gold Card
Posts: 354
Joined: Sun Jan 18, 2015 1:29 am

C++ Initialised Static (Class) Variables with Source and Explanation

Post by ql_freak »

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!)


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 :-)
User avatar
NormanDunbar
Forum Moderator
Posts: 2279
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: C++ Initialised Static (Class) Variables with Source and Explanation

Post by NormanDunbar »

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!)
I'm getting a 404 page when I follow that link. :(


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.
Derek_Stewart
Font of All Knowledge
Posts: 3975
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: C++ Initialised Static (Class) Variables with Source and Explanation

Post by Derek_Stewart »

Step closer to C++ for the QL!


Regards,

Derek
User avatar
ql_freak
Gold Card
Posts: 354
Joined: Sun Jan 18, 2015 1:29 am

Re: C++ Initialised Static (Class) Variables with Source and Explanation

Post by ql_freak »

NormanDunbar wrote: Thu Jan 11, 2024 11:57 am I'm getting a 404 page when I follow that link. :(
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
If it does not work go to my homepage (see my footer), click on the black triangle before "Softwareentwicklung" and in the pop down menu click on:

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 :-)
User avatar
tofro
Font of All Knowledge
Posts: 2702
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: C++ Initialised Static (Class) Variables with Source and Explanation

Post by tofro »

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
User avatar
NormanDunbar
Forum Moderator
Posts: 2279
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: C++ Initialised Static (Class) Variables with Source and Explanation

Post by NormanDunbar »

ql_freak wrote: Mon Jan 22, 2024 2:16 am
NormanDunbar wrote: Thu Jan 11, 2024 11:57 am I'm getting a 404 page when I follow that link. :(
Oops, I have thought, I have had answered this problem.
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.
Post Reply