Kenshin
How to print value of variable of enum type? Typedef enum {Linux, Windows, MacOS} os_type; os_type myOS = Linux; cout << "my os is: " << to_string(myOS) << endl;
If using C++23, include <utility> enum class OS_Type { Linux, Windows, MacOS }; // enum class OS_Type : int { Linux, Windows, MacOS }; // const auto os_t = OS_Type::Linux; std::cout << "my os is : " << std::to_underlying(os_t); If not C++23, you will have to std::static_cast instead of std::to_underlying.
Kurumi
Kurumi sent a code, it has been re-uploaded as a file
Using preprocessor to get variable name as string. Meow
Kurumi
Kurumi sent a code, it has been re-uploaded as a file
And please make this bot to tag users that messages was deleted and re-uploaded. Like this: @Kurumi1337 sent a code, it has been re-uploaded as a file
Luca
Guys does anyone know if it is possible to create a Singleton class derived from a non-Singleton Base class. And then through polymorphism associate it with a unique_ptr member of another class? Like: class Base{} class Singleton ex: public Base{} class My class{ My class(){ _member = Singleton::getInstance(); } std::unique_ptr<Base> _member; }
Rose
User Melody has 1/2 warnings; be careful! Reason: ad
Adam
Say i have a (linux) program, progA, which statically links libB.a. I do not have the source to progA, only the binary. Is it possible to re-link the program to a new version of libB.a, and generate a new executable with the changes in the newer library ?
ZIAUL HAQUE
Can you give me the Minimum Spanning Tree kruskal algorithm c++ implementation.
Rose
Can you give me the Minimum Spanning Tree kruskal algorithm c++ implementation.
User ZIAUL HAQUE has 1/2 warnings; be careful! Reason: only yourself can
Danya🔥
Say i have a (linux) program, progA, which statically links libB.a. I do not have the source to progA, only the binary. Is it possible to re-link the program to a new version of libB.a, and generate a new executable with the changes in the newer library ?
Interesting question, I don't think so. If you need to change only one function, I think it's possible to do it manually by replacing all of the references of the old function with new. Though I've never patched binary files.
Kenshin
Can you give me the Minimum Spanning Tree kruskal algorithm c++ implementation.
You should first do your own research (Google, YouTube, etc), then use this channel to inquire about an aspect of a C/C++ implementation that you did not understand as you did your due diligence. Avoid asking questions that indicate you want someone else to do the legwork for you.
borealis
Nopes. Not possible even with binary patching.
theoretically it is not impossible EDIT: it indeed is infeasible however
VD
theoretically it is not impossible EDIT: it indeed is infeasible however
Well if you have libversion1.a and libversion2.a and you don't have the source code, then basically you have to do all the plumbing work that a linker does manually. This means that you may have to remove the old library references and the code and data it carries, move around the code sections and the data sections to fit in the new one. Like you said, this is not impossible but the chances of getting it right and the final executable working as expected would have a very very low probability of success.
Adam
i thought so, but thought worth an ask! :)
Adam
in theory, the change in the new library is replacing one function call with another ... it may be possible to edit at the binary level, but probably not. could depend on inlining and all sorts
borealis
in theory, the change in the new library is replacing one function call with another ... it may be possible to edit at the binary level, but probably not. could depend on inlining and all sorts
it is not that difficult to patch a call with another. if it's inlined it might require more effort but it is still doable, you just need to patch the beginning of the inlined code to perform a call to the desired function instead (and potentially perform any caller cleanup)
.
I'm in c++20 <format> I want to this headers. But how can I install g++ that supports C++20?
\Device\NUL
That's still depend on the package manager
.
-std=c++20 ?
But the compiler says it can't find the header. 😂
.
-std=c++20 ?
Ah, it's solved. It works after installing gcc-11. Anyway thanks for your help 🙃
Hasni
How to add sound in cpp graphics game and how to add picture in it
Hasni
/start@MissRose_bot
Rose
/start@MissRose_bot
Heya :) PM me if you have any questions on how to use me!
Ludovic 'Archivist'
How to add sound in cpp graphics game and how to add picture in it
You can use Raylib if you want to make a 2D game
Ludovic 'Archivist'
How to add sound in cpp graphics game and how to add picture in it
It is pretty easy to add through CMake and FetchContent
Rose
User Serg has 1/2 warnings; be careful! Reason: yes
You
int num = 1; int count; for (count = 0; count < 5; ++count); num = 2 * num + num % (count + 1); what is the value of num after this program is executed...notice there is a semicolon after the for loop
David
Please is there any telegram channel or group where I can get coding pdf
harmony5 🇺🇳 ⌤
I guess they mean books?
Kenshin
Please is there any telegram channel or group where I can get coding pdf
Those are pirated books, except where the author provides them for free as public domain books, usually on their website. Pirated books are shunned upon in most communities/channels. You are better off searching for public domain books, like the guides authored by Brian "Beej Jorgensen" Hall, https://beej.us/guide/
Gary
Hii
klimi
Hii
the rules
VD
the rules
Where are the rules? The rules post - https://t.me/programminginc/453966 has been unpinned
Ziky
#admin
Danya🔥
You've probably dismissed it yourself
Gary
damn
klimi
it should even be under some command
klimi
/rules
Rose
/rules
Click on the button to see the chat rules!
VD
Aah, I didn't know individuals can dismiss the pinned post for themselves. I thought the whole idea was for it to be always visible. My bad then
klimi
oh that stopped working...
Pavel
You've probably dismissed it yourself
I don't see them pinned as well, also I believe you can't unpin things for yourself in telegram anymore
klimi
it's still in the description, so it's fine
Pavel
Huh, I don't have that button for several updates already 🤔
Pavel
Ah, nevermind it appears in cases only only one message is pinned
Gary
whats the topic here
Danya🔥
whats the topic here
Are you able to read the title of the chat?
Gary
nop
Danya🔥
nop
Do you have vision disabilities?
Gary
ya
Gary
according to the group title even u are not talking about the topic its mentioned here ... lol
David
Any Nigerian in the house
Rose
Any Nigerian in the house
User David has 1/2 warnings; be careful! Reason: offtop
Rose
User Pippi has 1/2 warnings; be careful! Reason: offtop
Gary
This groups admin is a whore
Rose
Another one bites the dust...! Banned Gary. Reason: no, you
az
Hello, coders! Currently i am learning new features of c++20 with ASIO (part of BOOST). I came across such a snippet and can't understand its meaning: asio::steady_timer timer(co_await this_coro::executor); What is the strange timer init arg?
King
Hi
.
I am studying C++11, and it is said that when an object or value is thrown as an exception, when an exception occurs, the original object goes out of scope and is freed from memory as it moves up the stack, so clone always occurs once or more. So, when creating an exception class, need to create a clone constructor. What I'm curious about here is If none of the class' internal members uses dynamic memory allocation, can I use the default clone constructor?
VD
I am studying C++11, and it is said that when an object or value is thrown as an exception, when an exception occurs, the original object goes out of scope and is freed from memory as it moves up the stack, so clone always occurs once or more. So, when creating an exception class, need to create a clone constructor. What I'm curious about here is If none of the class' internal members uses dynamic memory allocation, can I use the default clone constructor?
Where did you read this? This is not correct. Though the standards don't specify where an exception object is allocated, it does specify that the exception objects lives on when the stack is unwound. Most implementations allocate the exception object on the heap. So it is not true that the exception object is destroyed as you keep moving from one stack frame to the next
.
Why C++11? Much newer standards have been published?
Yes, but the C++20 book hasn't arrived yet, so I'm reading this book.