Anonymous
wow the GUI integration is nice
I have not used it. Just searched for it after your post. It was made available only in March of this year
Anonymous
I have not used it. Just searched for it after your post. It was made available only in March of this year
ye same. i just knew that it existed when trying to install cmake and clang-tidy support for visual studio (all three are optional components)
Anshul
If I set a breakpoint somewhere, so does the debugger do something like this. Executes the program till that breakpoint and waits at that breakpoint??
Anonymous
If I set a breakpoint somewhere, so does the debugger do something like this. Executes the program till that breakpoint and waits at that breakpoint??
Yes. When a breakpoint is hit, it results in a special trap instruction and the OS on seeing that trap instruction gets the interrupt associated with it which would be that of the debugger. The debugger uses this interrupt handler to set the CPU in a special mode where it runs one instruction after the other (pipelining is diasbled) and following the istruction it traps into the debugger again. This is how the debugger takes control of your program's execution.
Nganza
Hello
Sandeep
If I create a class and in the constructor I create a stack and dont give it any data then can I add to that stack later??
Sandeep
Explain the question more please
I read that uninitialised local variables cant be used
Sandeep
class Freqstack { public: Freqstack() { stack<int> s; unordered map<int, int> m; } void push(int val) ( s.push(val); m[val]++; } int pop() { } };
Rahul
Can anyone help me to understand this line if a =0 b= ++a + ++a;
Rahul
what should be value of b
Anonymous
Can anyone help me to understand this line if a =0 b= ++a + ++a;
most recent conversation - https://t.me/programminginc/410990 to https://t.me/programminginc/411003
Anonymous
this topic has been argued multiple times here. you can search "undefined" if you want more iterations of the same discussion.
Rahul
thank you ☺️
Anonymous
class Freqstack { public: Freqstack() { stack<int> s; unordered map<int, int> m; } void push(int val) ( s.push(val); m[val]++; } int pop() { } };
This wont even compile. You cant access s and m in push method. You should make them data members instead of local variables
Anonymous
Like write them outside the contrsuctor
Like: class Freqstack { private: stack<int> s; unordered map<int, int> m; public: Freqstack() = default //Rest of your class };
Sandeep
void push(int val) { s.push(val); m[val]++; if(m[val]>max) { max=val; } }
Since there already a function push...but we are writing a new push function with same name..it's not working how to solve
Sandeep
Your push function is in class FreqStack. Put your full code in pastebin.com
I pasted there ..do I download it and send it to you
Sandeep
paste the link here
https://pastebin.com/sbPdnLe0
Anonymous
https://pastebin.com/sbPdnLe0
Your code is not even in a compilable state. But even otherwise, I dont see any reason why the compiler would complain of a clash. As long as your push and pop are in FreqStack class's namespace there should not be any issues.
Anonymous
25
Look at LIne 22: stack int> temp; while(s.top()!=max) temp.push(s.pop()); What is temp? You cant ask for help here with silly coding issues. Try to understand your compiler's error messages
Anonymous
Temp is a stack that I created in pop function
Yes but you have written stack int> templ. It should be stack<int>
Sandeep
In the original code it's there
Anonymous
In the original code it's there
If you cant properly paste your code and expect us to help, then we cant be bothered either
Sandeep
https://pastebin.pl/view/082abc27
Sandeep
https://pastebin.pl/view/082abc27
This is the original code
Anonymous
This is the original code
Did you check the interface for pop on stack?
Sandeep
Did you check the interface for pop on stack?
Yes this pop should return the most frequent element
Anonymous
Yes this pop should return the most frequent element
When I asked if you checked the interface, I meant if you read the documentation for it? https://en.cppreference.com/w/cpp/container/stack/pop
Anshul
@SilhouetteInDark I started debugging the code but when I step over and the debugging goes to input line, how to give input
Anonymous
Anshul
It is not allowing to type anything
Anonymous
It is not allowing to type anything
It should unless there is some setting that you have to change explicitly. Just search for it online. Not familiar with Visual Studio
Anshul
Okay
Anshul
@SilhouetteInDark there's a exception thrown at line number 26, segmentation fault. can you explain why?
Anshul
if debugger stops at some line lets say line no.a then does it mean the previous line thrown exception?? or does it mean line a thrown exception
Anonymous
if debugger stops at some line lets say line no.a then does it mean the previous line thrown exception?? or does it mean line a thrown exception
Debugger will usually indicate the line that is to be executed next. So if an exception is thrown it will be at the previous line
Anshul
How am I supposed to know what is line 26
sorry i thought the code i sent before had line numbers. my mistake. anyways see this https://pastebin.com/vLAMwnt7
Anonymous
sorry i thought the code i sent before had line numbers. my mistake. anyways see this https://pastebin.com/vLAMwnt7
In your Node class, you are not initializing the left and right pointers. So they will have invalid values.
Anonymous
In your Node class, you are not initializing the left and right pointers. So they will have invalid values.
If you call insert on root->left or root->right, it will be on invalid pointer values which will lead to Undefined Behavior
Anshul
now it's running fine
Anonymous
thanks alot
Next time, dont ask why it is running on an Online IDE but not on your own computer. The problem is often with the one sitting at the computer and not with the compiler.
Anshul
😅yes, you're right
Anonymous
Programming language c++ how much income and how much money can be earned
If you’re doing computer science for money then it is not for you
Anshul
What is the meaning of c++11 c++14 and others. Like I'm learning c++ now and the tutorial from which I'm learning Data structures using c++ never even used such words
Anonymous
It’s just a C++ standard with new features
Anonymous
C++14 has more features than C++11
Anonymous
The latest standard I think rn is C++20
Anshul
Anonymous
I don’t use C++ I’m not sure
Anonymous
I don’t think knowing a older standard limits you from doing something
Anonymous
It limits you from using the added features
Anshul
I don’t use C++ I’m not sure
What language you use?
Anonymous
C
Anonymous
The latest standard is C17 that came out in 2017
Anonymous
Like what are the features?
https://isocpp.org/std/status
Anonymous
The Linux kernel is written in C90 i believe and it does peak computing
Pavel
Like what are the features?
I usually use this page to find at which standard a C++ feature become available. https://en.cppreference.com/w/cpp/compiler_support
Anonymous
The Linux kernel is written in C90 i believe and it does peak computing
It uses C99 mostly. C11 and C17 didnt add as many features to the language as C++11/C++17/C++20 did. So C99 is still very relevant today. But programming in C++03 mode would be frowned upon now. Most of the companies have moved to C++14 compilers now and the new style of c++ programming is called Modern C++ programming
Anshul
How do I know which version I'm using