Ehsan
Ahh I thought there was something interesting
Danya🔥
Ahh I thought there was something interesting
I build compilers Interesting enough? :)
Ehsan
you work on building compilers?
Michel
I have this function: template<typename stepper_type, typename system_type, typename state_type, typename scalar_type, typename observer_type> int integrate(stepper_type stepper, system_type sys, state_type x, scalar_type t0, scalar_type dt, int Nsteps, observer_type obs){ //stuff } I want the last argument to be omitable, how can I achieve that?
Michel
That last one is meant to be called inside the function, I guess I'll just make an overload without that argument and call this function with an empty lambda as obs
2105607_Arpit sahu
#include<iostream> using namespace std; void merge(int *arr,int l,int mid, int r ) { int n1=mid-l+1; int n2=r-mid; int arr1[n1],arr2[n2]; int index=l; for(int i=0;i<n1;i++) { arr1[i]=arr[index++]; } index=mid+1; for(int i=0;i<n2;i++) { arr2[i]=arr[index++]; } int i1=0,i2=0,k=l; while (i1<n1&&i2<n2) { if (arr1[i1]<arr2[i2]) { arr[k++]=arr[i1++]; }else { arr[k++]=arr[i2++]; } } while (i1<n1) { arr[k++]=arr[i1++]; } while (i2<n2) { arr[k++]=arr[i2++]; } } void merge_sort(int *arr,int l,int r) { if(l>=r) { return; } int mid=(l+r)/2; merge_sort(arr,l,mid); merge_sort(arr,mid+1,r); merge(arr,l,mid,r); } int main() { int arr[8]={7,2,12,0,5,3,7,6}; merge_sort(arr,0,7); for (int i = 0; i < 8; i++) { cout<<arr[i]; /* code */ } return 0; }
Nobody🪲
#include<stdio.h> int main() { int yos; char g,qual,X; printf("enter years of service:"); scanf("%d",&yos); printf("enter gender and qualification:\n"); scanf("%c%c",&g,&qual); (g=='M'&&yos>=10&&qual=='P'?printf("15000"):g=='M'&&yos>=10&&qual=='G'||g=='M'&&yos<10&&qual=='P'?printf("10000"): g=='F'&&yos>=10&&qual=='P'?printf("12000"):g=='F'&&yos>=10&&qual=='G'?printf("9000"):g=='F'&&yos<10&&qual=='P'?printf("10000"): g=='F'&&yos<10&&qual=='G'?printf("6000"):X); return 0; }
Nobody🪲
Whats wrong here? Expected output is to determine the salary according to gender qualification and years of service
Anonymous
I have this function: template<typename stepper_type, typename system_type, typename state_type, typename scalar_type, typename observer_type> int integrate(stepper_type stepper, system_type sys, state_type x, scalar_type t0, scalar_type dt, int Nsteps, observer_type obs){ //stuff } I want the last argument to be omitable, how can I achieve that?
You could do something like: template<typename stepper_type, typename system_type, typename state_type, typename scalar_type, typename observer_type = decltype([](){})> int integrate(stepper_type stepper, system_type sys, state_type x, scalar_type t0, scalar_type dt, int Nsteps, observer_type obs = observer_type()){ //stuff } Just remembered that this would work only in C++20 but. Lambda expressions are not allowed in unevaluated contexts before C++20. So this code will not compile on C++17.
Nobody🪲
Why you want nested ternary ? It's bad practice
Im a beginer thats why im trying to solve any question with every possible way to learn
Pavel
Im a beginer thats why im trying to solve any question with every possible way to learn
Use if-else instead, ternaries are unreadable and very easy to do wrong
Nobody🪲
Okay*
Nobody🪲
Thank u
Anonymous
I'd replace the lambda with the simplest std::nullptr_t
He said obs is a callable and that he expects to make a call to it within the body of the function. He wanted it to be a no-op. How would a nullptr_t work without explicit checking again to see if it is a callable or not by means of either overloading or an explicit check inside the code?
OTAKU
Will a long-integer work on a 32 bit system is there an any relation between 32 bit data type and 32 bit system?
Anonymous
Will a long-integer work on a 32 bit system is there an any relation between 32 bit data type and 32 bit system?
https://stackoverflow.com/questions/330374/long-long-implementation-in-32-bit-machine
Anonymous
Good day. I need a mentor please.
Artur
Hello friends, I hope you are all well. I'm going to ask you a question that I know is typical of people without programming knowledge, but let me explain the context. I already know programming in PHP and JavaScript, also in C and C++ although I am a beginner in these two. Now, at the university I must focus on one of the two, and I ask you this question so that it can be answered from a personal point of view, which one would you focus on? , C or C++ and why? Sorry if my english it's not perfect.
I would definitely go for C++, after all you will be able to understand C as well. My first job in programming was actually related to C back then we were developing operating system, I absolutely hated it every single day. And quite soon I changed the company and started working with C++ till the day. To be honest don’t just focus on language, it’s just a tool, focus also on architecture and other technologies definitely work on understanding how cmake works, shell scripting abilities, python and perhaps at least basic understanding of ruby and quite soon you will be in well payed position
\Device\NUL
Will a long-integer work on a 32 bit system is there an any relation between 32 bit data type and 32 bit system?
data system model isn't portable since OS and Arch implementation is different
Luis
Depends on what you wanna do. If you wanna work on researching low-level stuff and performance is something very important, go with C, C++ or Rust. If not, Javascript is enough
Yes, this is clear to me. but since the university requires me C or C++, that's why the question of deciding one or the other for now. JavaScript it's for continue work on web developing, this is other thing to me.
Marcio
If you want to learn C too (our brains has such a capacity to know more than one language!), I recommend the program (7 courses) “C and Linux” from Dartmouth Univ. at EdX.org; the free version enable you to do all the exercises, except the last one. I stayed out from the comp science world, returned by “remembering” C with this course and it was a really good thing for me.
Marcio
Now I inside C++, seeing for the first time the OO stuff, and reading books about embedded systems - stuff I worked with many years ago but has no formal knowledge.
Marcio
But, of course, C++ is a superset of C.
Luis
But, of course, C++ is a superset of C.
Yes, that's how I understand it. You can even understand C, knowing C++
Mini
Anyone have crack version of SQL yog enterprise
Pavel
Yes, that's how I understand it. You can even understand C, knowing C++
Not really, I was working with C++ for more than five years before I understood that they are fairly different, both in way of thinking and writing code, and also what is allowed or not by the language (both strictness of language constructs and what is UB or not). Before I thought "Ah, I work with C++, of course I know C" :D
Ehsan
No
Actually, its
\Device\NUL
Ehsan
In c even the basic stuff (like String manipulation) need to be done from scratch or go and find a good library for something
Ehsan
but in C++ there are lots of standard libraries that makes things much easier for beginners
\Device\NUL
Hard to understand and hard because need extra works is different
Ehsan
nobody use 100% of a language
Jagadeesh
#include<iostream> using namespace std; #include<set> int main(){ set<int> s{1,2,3,4,5,56}; auto it=s.lower_bound(3); cout<<it-s.begin(); }
Jagadeesh
how to get that index
Jagadeesh
getting error in that cout line
Anonymous
what is the error info?
Marcio
What is it-s?
Anonymous
#include<iostream> using namespace std; #include<set> int main(){ set<int> s{1,2,3,4,5,56}; auto it=s.lower_bound(3); cout<<it-s.begin(); }
There is no concept of index in a set. The iterators of set don't support operator- unlike the iterators of vector, deque, array or string.
Jagadeesh
i think we can use distance function to get the index
Anonymous
try *it?
Anonymous
i think we can use distance function to get the index
It will give you the number of steps required to reach one iterator fromthe other as long as one is reachable from the other. But that is not equivalent to index. Sets don't store elements in the order of insertion. Moreover a new insertion can affect how the elements are located. So you should not be doing this. If you need indexes, use a container that is relavant for that usage
Aristo
Anyone know any other projects like: libsrt, safeclib, datatype99 or libcello?
Aristo
Yes C++
I meant something good
Danya🔥
I meant something good
C is not good :)
Aristo
C is not good :)
right. it isn't just good it is the greatest.
Ramil
C++ just has way too much imo
Ramil
C is straight and small, even kids can learn it
Danya🔥
C, on the other hand, has nothing
Dima
You can still write c in c++
Dima
c with classes sounds good
Dima
I hope current team separates and will stop making nonsense
Dima
Ramil
You can still write c in c++
I know, compiler is optimized for c++ though
Ramil
what makes c++ appealing is it has everything so software development is easier, but everything has cost to it.
Anonymous
emm