olli
How ? Can you tell me the syntax?
Example using two Template parameters #include <string> template <class K, class V> struct Foo { K key; V value; }; int main() { Foo<std::string, int> f{ "Hello", 123 }; }
Artöm
graph<int> g;
Anonymous
You didn't specify template argument while calling
Thanks I fix it by your suggestion customConfig<isn’t>(...)
Anonymous
Why?
1) it's compiler-depended 2) it's hard to track real dependencies of your code
Anonymous
Bol na q
/warn speak Hindi somewhere outside of the chat
Anonymous
Okh
Himanshu
Hi
Anonymous
Hi
Hi
Vipul
#include <bits/stdc++.h> #include<iostream> #include<stack> #include<string> #include<cmath> using namespace std; #define max 100 int postfixevaluate(string str); bool isdigit(char str); bool isoperator(char str); int operation(char operators , int operand1, int operand2); class Stack{ // int top; public: int arr[max]; int top; Stack(){ top=-1; } bool push(int x); int pop(); }; bool Stack:: push(int x){ if(top>=(max-1)){ cout<<"overflow"; return false; } else{ arr[++top]=x; return true; } } int Stack::pop(){ if (top<0){ cout<<"underflow"; return 0; } else{ char x=arr[top]; cout<<arr[top]; top--; return x; } } int main(int argc, char *argv[]){ string expression; cout<<"enter postfix expression"; getline(cin,expression); cout<<"the result is"<<postfixevaluate(expression); cout<<expression; return 0; } int postfixevaluate(string str){ stack<int> S; for(int i=0;i<str.length();i++){ cout<<"hello"; if(str[i]==' '||str[i]=='.') continue; //cout<<str[i]; /*else if(str[i]=="{"|| str[i]=="(" ||str[i]=="[" ) S.push(str[i]); else if(str[i]=="}"|| str[i]==")" ||str[i]=="]"){ if(str[i]=="}") while(top!="{") S.pop(); else if(str[i]==")") while(top!="(") S.pop(); else while(top!="]") S.pop(); }*/ else if(isoperator(str[i])){ cout<<"hello1"; int operand1= S.top(); S.pop(); cout<<"hello2"; int operand2= S.top(); S.pop(); cout<<"hello3"; int ans = operation(str[i], operand1, operand2); S.push(ans); cout<<"hello4"; } else if(isdigit(str[i])){ cout<<"hello5"; int operand=0; while(i<str.length()&& isdigit(str[i])){ operand=(operand*10)+ (str[i]-'0'); cout<<"hello6"; i++; } i--; cout<<"hello7"; S.push(operand); cout<<"hello8"; } } cout<<"hello9"; return S.top(); //return 0; } bool isdigit(char str){ if(str>=0 && str<=9) return true; else return false; cout<<"hello10"; } bool isoperator(char str){ if(str=='+'||str=='-'||str=='*'||str=='^'||str=='/') return true; else return false; cout<<"hello11"; } int operation(char operators, int operand1, int operand2){ int ans=0; if(operators ='+') ans = operand1 + operand2; else if(operators =='-') ans = operand1 - operand2; else if(operators =='*') ans = operand1 * operand2; else if(operators =='^') ans = pow(operand1,operand2); else if(operators =='/') ans = operand1/operand2; cout<<"hello12"; return ans; } I am trying to evaluate the postfix expression using C++ program, but this code is showing segmentation fault error, can anyone help me where is the error, it will be more helpful.
Artöm
#include <bits/stdc++.h> #include<iostream> #include<stack> #include<string> #include<cmath> using namespace std; #define max 100 int postfixevaluate(string str); bool isdigit(char str); bool isoperator(char str); int operation(char operators , int operand1, int operand2); class Stack{ // int top; public: int arr[max]; int top; Stack(){ top=-1; } bool push(int x); int pop(); }; bool Stack:: push(int x){ if(top>=(max-1)){ cout<<"overflow"; return false; } else{ arr[++top]=x; return true; } } int Stack::pop(){ if (top<0){ cout<<"underflow"; return 0; } else{ char x=arr[top]; cout<<arr[top]; top--; return x; } } int main(int argc, char *argv[]){ string expression; cout<<"enter postfix expression"; getline(cin,expression); cout<<"the result is"<<postfixevaluate(expression); cout<<expression; return 0; } int postfixevaluate(string str){ stack<int> S; for(int i=0;i<str.length();i++){ cout<<"hello"; if(str[i]==' '||str[i]=='.') continue; //cout<<str[i]; /*else if(str[i]=="{"|| str[i]=="(" ||str[i]=="[" ) S.push(str[i]); else if(str[i]=="}"|| str[i]==")" ||str[i]=="]"){ if(str[i]=="}") while(top!="{") S.pop(); else if(str[i]==")") while(top!="(") S.pop(); else while(top!="]") S.pop(); }*/ else if(isoperator(str[i])){ cout<<"hello1"; int operand1= S.top(); S.pop(); cout<<"hello2"; int operand2= S.top(); S.pop(); cout<<"hello3"; int ans = operation(str[i], operand1, operand2); S.push(ans); cout<<"hello4"; } else if(isdigit(str[i])){ cout<<"hello5"; int operand=0; while(i<str.length()&& isdigit(str[i])){ operand=(operand*10)+ (str[i]-'0'); cout<<"hello6"; i++; } i--; cout<<"hello7"; S.push(operand); cout<<"hello8"; } } cout<<"hello9"; return S.top(); //return 0; } bool isdigit(char str){ if(str>=0 && str<=9) return true; else return false; cout<<"hello10"; } bool isoperator(char str){ if(str=='+'||str=='-'||str=='*'||str=='^'||str=='/') return true; else return false; cout<<"hello11"; } int operation(char operators, int operand1, int operand2){ int ans=0; if(operators ='+') ans = operand1 + operand2; else if(operators =='-') ans = operand1 - operand2; else if(operators =='*') ans = operand1 * operand2; else if(operators =='^') ans = pow(operand1,operand2); else if(operators =='/') ans = operand1/operand2; cout<<"hello12"; return ans; } I am trying to evaluate the postfix expression using C++ program, but this code is showing segmentation fault error, can anyone help me where is the error, it will be more helpful.
Bro use pastebin
Vipul
Bro use pastebin
How to use that pastebin?😅
Artöm
Give us a link to your code
Artöm
It's hard to read 10+ lines of code in tg
Artöm
How to use that pastebin?😅
Paste code, get link
Anonymous
#include <bits/stdc++.h> #include<iostream> #include<stack> #include<string> #include<cmath> using namespace std; #define max 100 int postfixevaluate(string str); bool isdigit(char str); bool isoperator(char str); int operation(char operators , int operand1, int operand2); class Stack{ // int top; public: int arr[max]; int top; Stack(){ top=-1; } bool push(int x); int pop(); }; bool Stack:: push(int x){ if(top>=(max-1)){ cout<<"overflow"; return false; } else{ arr[++top]=x; return true; } } int Stack::pop(){ if (top<0){ cout<<"underflow"; return 0; } else{ char x=arr[top]; cout<<arr[top]; top--; return x; } } int main(int argc, char *argv[]){ string expression; cout<<"enter postfix expression"; getline(cin,expression); cout<<"the result is"<<postfixevaluate(expression); cout<<expression; return 0; } int postfixevaluate(string str){ stack<int> S; for(int i=0;i<str.length();i++){ cout<<"hello"; if(str[i]==' '||str[i]=='.') continue; //cout<<str[i]; /*else if(str[i]=="{"|| str[i]=="(" ||str[i]=="[" ) S.push(str[i]); else if(str[i]=="}"|| str[i]==")" ||str[i]=="]"){ if(str[i]=="}") while(top!="{") S.pop(); else if(str[i]==")") while(top!="(") S.pop(); else while(top!="]") S.pop(); }*/ else if(isoperator(str[i])){ cout<<"hello1"; int operand1= S.top(); S.pop(); cout<<"hello2"; int operand2= S.top(); S.pop(); cout<<"hello3"; int ans = operation(str[i], operand1, operand2); S.push(ans); cout<<"hello4"; } else if(isdigit(str[i])){ cout<<"hello5"; int operand=0; while(i<str.length()&& isdigit(str[i])){ operand=(operand*10)+ (str[i]-'0'); cout<<"hello6"; i++; } i--; cout<<"hello7"; S.push(operand); cout<<"hello8"; } } cout<<"hello9"; return S.top(); //return 0; } bool isdigit(char str){ if(str>=0 && str<=9) return true; else return false; cout<<"hello10"; } bool isoperator(char str){ if(str=='+'||str=='-'||str=='*'||str=='^'||str=='/') return true; else return false; cout<<"hello11"; } int operation(char operators, int operand1, int operand2){ int ans=0; if(operators ='+') ans = operand1 + operand2; else if(operators =='-') ans = operand1 - operand2; else if(operators =='*') ans = operand1 * operand2; else if(operators =='^') ans = pow(operand1,operand2); else if(operators =='/') ans = operand1/operand2; cout<<"hello12"; return ans; } I am trying to evaluate the postfix expression using C++ program, but this code is showing segmentation fault error, can anyone help me where is the error, it will be more helpful.
Anonymous
Read the rules!
Vipul
It's hard to read 10+ lines of code in tg
Okk Wait i am giving you the link!
Anonymous
isdigit is wrong
Anonymous
And there's a standard function for that I dunno why you need your own
Vipul
And there's a standard function for that I dunno why you need your own
In Indian Education System,In our college lab, they don't want to use the inbuilt functions, they want that we built it from scratch, otherwise they will fail us in practical😞
Ilya
Hey everybody! I'm currently learning cpp and plan to learn it to an intermediate level (generics and stl). Does anyone know how much time it will take to learn to develop desktop applications using qt and cpp?
3-5 years. First, don't develop GUI applications until you get to know the language itself. Second, C++ itself have no facilities to develop GUI desktop applications at all, so you will have to study OS API (written mostly in C) and use it, this is a separate task. Qt is a very good alternative, but then you will have to learn Qt which is another separate task, too.
Dima
Anonymous
Where is the link, @vipul2097?!
Vipul
Where is the link, @vipul2097?!
http://tpcg.io/tlzrpQ
Anonymous
http://tpcg.io/tlzrpQ
You've been told to use pastebin, but you used this...
Vipul
You've been told to use pastebin, but you used this...
Sorry, Sir I don't know how to use pastebin, wait i will first watch tutorial on pastebin then give you the link of that, will it be fine?😞
Anonymous
Thanks for your answer! If I learn os calls based gui, wouldn't it be limited to that particular os? Isn't it better to learn something cross platform like qt?
It's limited of course Ilia says that you need to learn C++ first, than Qt Learning Qt should be a separate task after learning C++ to a decent level, because Qt is like a different "system"
Anonymous
Vipul
You managed it
Yes, Actually First time i heard about pastebin😅Thats why
Ilya
Thanks for your answer! If I learn os calls based gui, wouldn't it be limited to that particular os? Isn't it better to learn something cross platform like qt?
wouldn't it be limited to that particular os? Surely it will to learn something cross platform like qt -- it is always better but you are not always able to use cross-platform solutions
Being
Hello All...! Best book for C programming learning.
Anonymous
Hii
Anonymous
hi guys anyone online to help me with my answer
Anonymous
question: https://www.hackerrank.com/challenges/birthday-cake-candles/problem || answer: https://del.dog/cpluspluscode.cc
Anonymous
anybody there?
Anonymous
1. code is not working 2. https://del.dog/cpluspluscode.cc
Anonymous
1. code is not working 2. https://del.dog/cpluspluscode.cc
https://www.hackerrank.com/challenges/birthday-cake-candles/problem
Anonymous
1. code is not working 2. https://del.dog/cpluspluscode.cc
So if is not working, fix it Kinda obvious, I think
Anonymous
So if is not working, fix it Kinda obvious, I think
i cannot find the problem why its not functioning that way
Anonymous
Anonymous
i cannot find the problem why its not functioning that way
It's wrong. You have to make array of size n. Also you've applied wrong logic.
Anonymous
It's wrong. You have to make array of size n. Also you've applied wrong logic.
i am checking if the no of candles is equal to her age else 1 minus her age then 2 minus that what the question wants me to do right?
Anonymous
The question just wants to find the no. Of tallest candles.
Anonymous
The question just wants to find the no. Of tallest candles.
it will count the candles if its equal to her age if not it will reduce 1 from his age
Anonymous
The question just wants to find the no. Of tallest candles.
can you provide better logic to the given problem it would be helpfull?
Dr Giancarlo
There's a thing, called debugging
Also exist the Ghost in the Shell
Dr Giancarlo
A joke
Anonymous
can you provide better logic to the given problem it would be helpfull?
1. Make an array of size n. 2. Sort the array in descending order. 3. For loop till a[i] ==a[i+1] Print i+1
Anonymous
can you code it sorry for asking for too much
How are you going to learn if I code?
Anonymous
How are you going to learn if I code?
i am trying another thing then will compare
Anonymous
No, code it yourself
where's maxi?
Anonymous
can you write?
/warn code it yourself, again
Anonymous
😂
manas
Thanks for your input! 👍👍
Anonymous
No
i am trying your method such that i am sorting array(assending) then checking that if the last element that is greatest one is occuring how many times in that array and returning that but i am using 3 loops for it is there any way to reduce complexity?
Anonymous
or any better way to solve
MᏫᎻᎯᎷᎷᎬᎠ
/report
Dima
/ban Shop ad, unrelated.