klimi
how to simulation binary search tree on graphic c++
You can just code it and display it while searching?
Long
i want the result to show the tree
Long
now result is straight line
Anonymous
now result is straight line
Does your binary tree use a height balancing algorithm?
Delious
how people on codechef have soo good c++ skills, like the code which i write is the basic and what they write is advanced , how do i get there? how do i advance my c++ skills? any book? course?
Delious
i want 2 know
Anonymous
No
Ok, so if I input the numbers 1,2,3,4,5,6 etc in order into your binary tree, then you do realise that your binary tree will be a straight line then without a height balancing algorithm
Long
yes
Long
so how to use height balancing algorithm?
Leovan
Hi, how default values for struct fields works? It modify default constructor or smth? For example: struct A { int x = 5; };
Danya🔥
Hi, how default values for struct fields works? It modify default constructor or smth? For example: struct A { int x = 5; };
It's just default If you don't initialize your field with a value in the initialization list of a constructors, compiler will insert the initialization with the default value you provided
P
Can anyone give me a source where leetcode after contest discussion happens and it's free?
P
Sorry if I bothering you guybut it frustrating me when I can not see that I am not been able to solve some problem.. After contest I need to learn how the code works..... So that's the thing 😔
Leovan
It's just default If you don't initialize your field with a value in the initialization list of a constructors, compiler will insert the initialization with the default value you provided
1. Is it related to the constructor in any way (does it modify it somehow or is it a separate thing)? 2. If i don't provide default value for field: Is it guaranteed by the standard that field will be initialized with 0? Or in the field will be garbage from memory (like with local variables)?
P
There's a "discussion" button for each leet code problem
Did you hear me properly....i didn't told about regular problems.... I told about contest problems
P
In the after contest discussion sec very few people actually discusses the problem
Danya🔥
Did you hear me properly....i didn't told about regular problems.... I told about contest problems
Anyways, this is not related to this chat Go to LeetCode support and ask them https://leetcode.com/discuss/
P
😐
Leovan
1. I don't understand the question
By modify I mean something like implicitly changing the default constructor: // from A(int x = 0) : x(x) {} // to A(int x = 5) : x(x) {}
Danya🔥
It doesn't change parameters of a constructor
Danya🔥
It's guaranteed that your fields are initialized after { of any constructor
Danya🔥
They are default initialized
Danya🔥
They are default initialized
But a default value for something like int can be implementation-defined, maybe a junk value, I'm not sure here
Danya🔥
Maybe Madhu knows more
Danya🔥
so they initialize fields after constructor?
Before the body of the constructor
Ludovic 'Archivist'
how people on codechef have soo good c++ skills, like the code which i write is the basic and what they write is advanced , how do i get there? how do i advance my c++ skills? any book? course?
My advice would be to practice and to use the standard algorithms and datastructures a lot, to not use new unless it is absolutely required, to watch conferences on C++ (Sean Parent's Seasoning C++ comes to mind) and every now and then to go on C++ Quizz and try and answer a few questions
Leovan
Before the body of the constructor
Before the body: this means after constructor initializer list? 🙃 A(int x = 5) : x(x)
Danya🔥
Before the body: this means after constructor initializer list? 🙃 A(int x = 5) : x(x)
If they are not mentioned in the initializer list, the field will be initialized automatically
Danya🔥
It is written in the cppreference link I sent you
Leovan
okey. thank you
Ludovic 'Archivist'
By modify I mean something like implicitly changing the default constructor: // from A(int x = 0) : x(x) {} // to A(int x = 5) : x(x) {}
Yes, it is roughly the same. Keep in mind that constructor initializers are executed in the order of attributes declaration, and not in the order specified in the constructor
Ludovic 'Archivist'
If you initialize them with the constructor initializer, they will not be default initialized
Anonymous
But a default value for something like int can be implementation-defined, maybe a junk value, I'm not sure here
Whatever you have said is correct. And yes if a non static member primitive value is not initialised in the constructor initializer list or if it is not provided a default initial value in the class member field declaration (default initialization), it will take on undefined values.
Spam
You have access to an ecosystem that Microsoft has not touched. Why do you think they did WSL?
oh makes sense..ive been thinking to completly remove microsoft and switch to linux
Spam
Vmware is a drag sometimes
Erzbir
one to work,one to game or some job needs win
Кирилл
Good evening! Can you please suggest any books or resources where you can look up tricky c++ questions (preferably but not necessarily with answers), very preferably by the latest standards (minimum 17, but preferably 20-23). (It's easier for me to learn that way + control)
Кирилл
Define a tricky question
Where you have to think to say the answer. I imagine ideal questions like the ones Tanenbaum writes (e.g. in his book Modern Operating Systems), but only by modern c++ standards. Still good questions for me are the ones that pose some kind of problem, and you not only need to know the tool to solve it, but also have to guess exactly what to apply, and how to apply it. (There's a key point here in posing problems that are close to the real-world problems that might arise in development)
Adaita (MedTech | Healthcare)
Enabling clang-tidy in a codebase that exists several years is such a pain in the ass
clang-tidy is well integrated in the IDE and it suggests fixes for possible errors as I type in the code. I ran static analysis after 6 months of writing code, not a single error reported. Thanks to clang-tidy!
Alex 🍼
Please help with c++ code(all information in private message)
Alex 🍼
Adaita (MedTech | Healthcare)
Which platform ? Linux ?
Qt Creator IDE - cross-platform.
Ghasem
Not everyone uses ides
it could be enabled from CMake without using IDE/Editor.
Engineer
Qt Creator IDE - cross-platform.
You also developing Qt C++ apps?
Anonymous
Can someone give some difficult programming problems to solve
klimi
Can someone give some difficult programming problems to solve
there are online websites like leetcode, codewars and others; have you tried those?
Strife
Can anyone solve my problem? I want to make a simple program for practice I want to use two functions for this program The first function which takes and saves the person's information (such as name and password) The second function It asks the person to enter the details for the trustees again and if it is equal to what he entered in the first function, he will be allowed to enter (I know this is funny and you can write this program by writing in a function, but I like the connection of the function to understand each other better)
Strife
No one is gonna write the code for you
I don't need other people's code My only request is a small explanation
Danya🔥
What don't you understand?
Strife
How to manipulate something stored in one function in another function
Paras
Hey guys can someone explain this code about income tax in c to me
Chat Boss
Paras sent a huge message, it has been re-uploaded as a file float tax = 0, income; printf ("enter your income \n"); scanf ("%f", &income); if ..
Paras
what I don't understand is if my salary is 8 l then how will this work
Michel
If anyone can mentor me on this exercise on exercism.com I would appreciate. It's about concurrency in C++: I have a class of a bank account and want to be able to handle concurrent deposits and withdrawals, what I did was making the balance an atomic std::atomic<int> _balance = 0; Is this OK? Is there any other way? What would be the preferred approach?
smene
hi guys, I'd like to build a proxy server like Burp Suite, where could I start from? (C++)
Anonymous
If anyone can mentor me on this exercise on exercism.com I would appreciate. It's about concurrency in C++: I have a class of a bank account and want to be able to handle concurrent deposits and withdrawals, what I did was making the balance an atomic std::atomic<int> _balance = 0; Is this OK? Is there any other way? What would be the preferred approach?
I haven't checked the exercise but an atomic variable by itself can guarantee atomicity if it is standalone and you don't have multiple interrelated atomic variables where you need to manipulate them together. If account is the only variable you will be ever manipulating, then using an atomic variable would be the faster choice.
Anonymous
If anyone can mentor me on this exercise on exercism.com I would appreciate. It's about concurrency in C++: I have a class of a bank account and want to be able to handle concurrent deposits and withdrawals, what I did was making the balance an atomic std::atomic<int> _balance = 0; Is this OK? Is there any other way? What would be the preferred approach?
I just checked the question. Using atomic variables won't work here. If suppose say there are three people A, B and C. If A is sending 400 to B and B is sending 300 to C, and assuming A has 400, B has 0 and C has 0. Now suppose A-B transaction happens first and B-C transaction happens next. Now every transaction has two atomic variables involved. For A-B transaction, suppose the thread handling this transaction debits A's account and gets context switched before it can add to B's account. Now suppose the thread handling B-C runs, it will fail when it tries to debit 300 from B's account because the balance is 0. Ideally A-B transaction should have completed fully before B-C transaction is attempted. So the lesson here is that atomic variables don't guarantee transactional integrity. The other way to say this is that atomic variables are data race free but are still subject to race conditions one of which I highlighted above. One way to handle this problem would be using a lock for each account and conditional variables. When you lock an account use a cv to determine if the account balance allows it to proceed with the transaction.
Anonymous