Ziky
If it is for desktop I would say QT but just because it is the only thing I ever tried. (And Actually it will probably somehow work on android too).
Light
Well, Qt is whole different environment, isnt there a simple library just like python has tkinter
Light
And please not i am a beginner in gui
Pippi
Danya🔥
concious_soul
whats the best books if you want to start learning cpp
Light
i downloaded visual studio and shifted to it, why my visual studio has run option disabled and it gives weird error some HKey type when i press compile
Light
why everything is weird as compared to code? thousands of errors even i downloaded the full version which i mean 80 GB
Light
manually created
Pavel
manually created
Then what I would do is
1. Try to start from building a smaller example (one main.cpp)
Make sure that compiles.
2. Try to include some of your code, make sure include directories are correct (it may fail linking at this point)
3. Try to add other CPP files, make sure you add them correctly and linking passes without issues
4. Make sure you pass the correct compiler and linker arguments
5. If you have libraries, add one of them and make sure it links correctly
6. Add everything else
Light
when i followed from first step that is making cpp file i am getting no run option but i accidentally found that when i first create a project then cpp file it works
Light
i tried same thing in other languages, it works fine now
Manav
Light
i did everything
Light
well i was following wrong steps it works fine now
Light
by creating project first then file
Light
Manav
Does everything work now?
Light
obv not gaming one, i aint that mad
Light
Light
Indian tech guy saved me
Light
#include <iostream>
using namespace std;
class base
{
public:
int a;
void print()
{
cout << a << endl;
}
};
int main()
{
base obj{ 4 };
obj.print();
return 0;
}
Light
why do public members automatically get initialized???
Pavel
why do public members automatically get initialized???
As far as I know it's not only about public members
In this specific case I believe you use aggregate initializer, it has prerequisites to be used, and your class satisfies them
https://en.cppreference.com/w/cpp/language/aggregate_initialization
Light
oh i didnt know the name, i just kept using it when i found this happens
jay
hello
Arnold
what does this have to do with C++? Are they on a C++ pilgrimage?
Rai
what is the purpose of "default" and "switch" in c++?
Danya🔥
Rai
))
Light
I think he is linux user and cant install gogle
Light
Arnold
especially a long if else if else if else chain becomes much faster if you rewrite it into one big switch statement
Danya🔥
Danya🔥
With the recent compilers of course
\Device\NUL
Rai
Arnold
Do you have any proof for that? ;)
well, that's the theory at least, I don't know how smart compilers are. I could try making a little test. Without optimization, an if/else chain should create branching instructions that end up losing a lot of time, meanwhile a switch should be just a lookup table. I remember that Terry Davis in his TempleOS's HolyC optimized it even further that the lookup table's size is specified at compile time and becomes even faster.
I suppose I could give it try, I just finished work for today.
Light
Switches just look presentable
Arnold
okay Thanks Arnold
Even if ends up being just as fast, a switch statement is very elegant compared to a big if/else chain.
Light
Thats all
Light
Look if small codes are required switches
But if you writing Gta 7 or pubg mobile and checking some condition then implementing large code if else looks better
Light
Right everyone
Light
?
\Device\NUL
Arnold
for anything more than 3 cases, if/else looks absolutely horrible in my opinion. You lose track very easily
Danya🔥
Danya🔥
Here is an example, that they have just identical code: https://godbolt.org/z/nd9x54Ej6
Arnold
haha it's faster
Danya🔥
Arnold
let me post
Ludovic 'Archivist'
it basically comes down to simpler AST -> easier to write optimizations
Danya🔥
Well, maybe, but it is not the enough reason to choose switch over if and these microoptimizations are bad anyways :)
Arnold
XXXXX:~/telegram_testing$ time ./ifelse
real 0m0,361s
XXXXX:~/telegram_testing$ time ./switch
real 0m0,286s
Source codes:
https://pastebin.com/cqJpTThZ
\Device\NUL
lmao
Arnold
ran it 10 times and switch was always considerably faster.
One thing I tried to do was not have the remainder in a variable and check x % 7 every time in the if/else. I'd expect the compiler to take care of that but no, it ended up over 0.5s every time. Compiled with default gcc which is what most people use
\Device\NUL
Ludovic 'Archivist'
Danya🔥
\Device\NUL
Arnold
Danya🔥
For god's sake there are system calls, multiprocessing of the OS, whatnot
\Device\NUL
Smarted
Arnold
I'll try running it with -O0, might be fun to see if there's a change
Arnold
what do you mean
Ludovic 'Archivist'
it seems the switch case version shaves 2 comparisons
Ludovic 'Archivist'
\Device\NUL
If you don't we should end this nonsense convertation then
Arnold
:)