YVEF
Hi, Guys. Can someone tell me - generics and templates is the same or different?
Anonymous
Hi, Guys. Can someone tell me - generics and templates is the same or different?
No. Templates is more of compile time type system while generics in Java and C# work with type erasure. Templates in C++ is a Turing Complete pure functional programming language (but implementing the regular things available to you in a functional programming world can be a pain in the ass). Generics are more of a convenience. Having said that, Generics in C# is a much more cleanly implemented feature than the one in Java.
Anonymous
I mean generics and templates in c++. I Heard this is different but it can be wrong info
No there are not two things. Templates in C++ offer you the flexibility of generic programming.
Reserved
What happened 😕?
Anonymous
What happened 😕?
Do you have a specific question? This is not a "Hi...Hello....getting to know each other" group.
Reserved
Okay i get it but plz help me guys to learn programming
Reserved
Okay
Reserved
With which channel ?
Reserved
Whose channel is good in programming to learn effectively?
Talula
Was my reply deleted or it never went through?
Anonymous
Whose channel is good in programming to learn effectively?
https://m.youtube.com/playlist?list=PLo7g9OE1yqEKY4KxAiPpqA9gp7XOcPQ2V
Anonymous
Was my reply deleted or it never went through?
Yeah I deleted it by mistake when I was clearing up the other messages. Unfortunately there is no way to undo a wrong delete.
Strife
Whose channel is good in programming to learn effectively?
don't care which channel is better just go search learning c++ or other language
Strife
for now go for learn
Anonymous
Any path way what to learn after .. fundamental of C++
adult breastfeeding
How to learn c++ in online
You can use learncpp.com
adult breastfeeding
Or just go to udemy they have great courses
Anonymous
Or just go to udemy they have great courses
Any path way what to learn after .. fundamental of C++
adult breastfeeding
Any path way what to learn after .. fundamental of C++
Training, look into projects and other people's code in github
Reserved
Any path way what to learn after .. fundamental of C++
Go to udemy courses . There are lots of free and paid courses for every topic u want to study.
Luca
Hello guys, I've some problem related with g++ version. (I've a Mac OS) In particular, when I launch "g++ --version" I get that I've installed g++ 4.2.1 version. I would like to upload it to the most modern version, but I'm not able to do it. I've installed g++ with "xcode-select --install", also i did "brew install gcc" but when I go in usr/bin I only get g++ 4.2.1 version
CharlyHackr
good evening, someone, could explainme, beacuse signed char letraconsigno; letraconsigno = -65; printf("letraconsigno es %d y su valor decimal es %d. \n", letraconsigno, letraconsigno); in globals vary letraconsigno show '/191' but print -65 why ? thank you
Anonymous
Guys, Udemy instructor told this
Anonymous
That
Anonymous
s[ ] = "hello"; s[2 ]='g' ; // this is invalid
Anonymous
But when I run this command the output was heglo
Anonymous
His logic was that string literals are stored in code section
Anonymous
Part of memory
Anonymous
Please help 🙏🙏😑
klimi
His logic was that string literals are stored in code section
Some are... But Doesn't Char s[] = "hello"; Store it on stack?
Anonymous
Exactly
Al
s[ ] = "hello"; s[2 ]='g' ; // this is invalid
non writable string memory location is usually assigned with a pointer
Al
char * s = “billy joe”
Anonymous
Ok so that means this is stored in code section part or stack part?
Pyc
Hello
Pyc
I'm new here
Al
string will be stored in the code section
Al
the pointer not
Anonymous
Ok thanks
Anonymous
Hello
Anonymous
Guys
Anonymous
no there isn't
How about /usr/bin. There will be binaries like gcc-* where * is the latest version of the packaged binaries that brew offers. Search for file names in that pattern. If brew gave you no errors, then those binaries definitely exist somewhere.
Suka
His logic was that string literals are stored in code section
perhaps he declare with const keyword? like const char s[]="hello"; so s[2]='g' -> will be illegal?
Vikas
Hi
Vikas
Getting error #include<bits/stdc++.h> using namespace std; int* dummy(){ static int arr[5]{1, 2, 3, 4, 5}; return arr; } int main(){ for(int x: dummy()) cout<<x<<" "; }
Anonymous
Then how to print the data?
You will have to return both array pointer and the size and in main you use a regular for loop
Anonymous
Or use a vector
Anonymous
Or std::array
Vikas
This is working #include<bits/stdc++.h> using namespace std; int* dummy(){ static int arr[5]{1, 2, 3, 4, 5}; return arr; } int main(){ int* x = dummy(); for(int i=0; i<5; i++) cout<<x[i]<<" "; }
Vikas
Can't we find size from pointer?
Anonymous
This is working #include<bits/stdc++.h> using namespace std; int* dummy(){ static int arr[5]{1, 2, 3, 4, 5}; return arr; } int main(){ int* x = dummy(); for(int i=0; i<5; i++) cout<<x[i]<<" "; }
This is ok. This is the regular for loop that I was talking about. But here you are implicitly assuming the size is 5 instead of returning it from dummy.
Anonymous
Can't we find size from pointer?
No. The pointer returned from dummy is just an int*. It doesn't have details about the array. You could do this as well auto dummy()->int (*)[5]{ static int arr[]={1,2,3,4,5}; return &arr; } In C++14, the return type will also be inferred.
Suka
It will be 5* sizeof(int)
ooo yes hehe. nice n thanks
Aniket
Some are... But Doesn't Char s[] = "hello"; Store it on stack?
No string literals are stored in string litteral pool section on heap
Aniket
Anonymous
No string literals are stored in string litteral pool section on heap
Where string literals are stored is OS dependent. But they are most likely not stored on the heap. Most of the OSes offer a read only segment (certain smaller ones like those used in IoT may not offer a read only data section and may instead use a writable segment) which is where string literals are stored
Anshul
in c++ for string class when I use this operator += it's supposed to append only string to my already existing string. But if I try to append char to my string then also it gave me correct answer. I want to know will it append character as well all the time or it's UB string ans; ans+='a';
Anshul
Also I have this question, convert 2a3b4c to aabbbcccc. i did this question in o(n) space. can anyone suggest me an optimization to it
Anshul
#include<iostream> #include<string> using namespace std; int main() { string s="0a3b4c"; string ans; for(int i=0;i<s.length();i+=2) { int k=s[i]-'0'; char k_1=s[i+1]; while(k--) { ans+=k_1; } } cout<<ans; }
Anonymous
Can you give me a demo of it.
No. Check the documentation and do the coding yourself.
Anshul
Found it
Anshul
Is it because the size of string will be needed to change if the underlying array gets filled?