Anonymous
but how will the compiler know which class method I want to define?
Anonymous
ohh I removed RYDot:: in the class
Anonymous
yess this worked uwu
Anonymous
thx
Anonymous
Ok
Osoroshi
How to transform String to Int?
klimi
How to transform String to Int?
what do you mean? like... you want bigint?
Osoroshi
My number is recorded in String, but I need to use it as int
Osoroshi
I don’t have the Internet, only unlimited for instant messengers, so I can’t use the browser to search for simple solutions 😅😥
pavel
but how will the compiler know which class method I want to define?
Probably you don't show full code. You define operator in class definition
Anonymous
yes I just misunderstood but it's resolved now :3
Anonymous
My number is recorded in String, but I need to use it as int
#include <cstring> stoi(str.c_str());
⚛ Hz
#include <cstring> stoi(str.c_str());
std::stoi can accept std::string directly
Sylvester Lim
Hi , i have a question void swap(int *,int *); int main() { int num1=2,num2=-3; swap(&num1,&num2); return 0; } void swap(int *x,int *y) { int temp; temp = *x; *x = *y; *y=temp; } Does changing value of pointer variable in a function also change the value in main function ( as shown in code above)? I was under the impression that only reference variables can do such a change. Thnak you !
Natanim
after the function call, num1 is -3 and num2 is now 2
So, that means it only works if we call by reference. And calling it by value wouldnt change the variables right?
Sylvester Lim
So, that means it only works if we call by reference. And calling it by value wouldnt change the variables right?
I am calling the function by passing pointers here... calling it by value works as well after the swapping thingy I did in the code but i would have to print in the function directly
Anonymous
Hi,I am confused about which overloaded function testa() should be called.I dont know why. #include<iostream> using namespace std; int testa(const int* a){     cout<<*a+1<<endl;     return 0; } int testa(int* a){     cout<<*a<<endl;     return 0; } int main(){     int b=45;     int * const a=&b;     testa(a);     return 0; }
Pavel
So, that means it only works if we call by reference. And calling it by value wouldnt change the variables right?
Yes, in this case it's not by-reference, it's by-pointer though. When you pass by-value, you copy the object and the function works with the copy
Thadeu
Is there some advantage in pass a function call as argument (1) instead of declare a variable to be used on calling (2)? Ex 1. funcA(funcB()); Ex 2. int arg = funcB(); funcA(arg);
Anonymous
Hi,I am confused about which overloaded function testa() should be called.I dont know why. #include<iostream> using namespace std; int testa(const int* a){     cout<<*a+1<<endl;     return 0; } int testa(int* a){     cout<<*a<<endl;     return 0; } int main(){     int b=45;     int * const a=&b;     testa(a);     return 0; }
It would call the second function. Both the functions are pass by values so the top level const on the argument i.e. int* const a = &b would be ignored. Now both the functions would match but the second function is an exact match while the first function would require a const conversion. So overload resolution rules prefer the second function. If on the other hand if your code in main were like this: int const * const a = &b; testa(a); then it would call the first function
Anonymous
Is there some advantage in pass a function call as argument (1) instead of declare a variable to be used on calling (2)? Ex 1. funcA(funcB()); Ex 2. int arg = funcB(); funcA(arg);
It would matter in generic code and also functions that are overloaded based on whether they take lvalue or rvalue references or template functions with a universal reference. The first call passes a prvalue (assuming it returns an int) while the second call passes a lvalue argument.
Y'amiGami
i can't really find the error in this code: https://pastebin.com/GacAM9nQ what i'm trying to do is: ask data of 2 cars and print it.
Y'amiGami
automobili salone[2];? Undefined
yeah sorry i quickly translated the code from italian to english, i meant car salone[2]
Pavel
So is pass by pointer capable of changing the original variable in main function , sir?
kind of yes, but you need to understand what is happening first you have a value, it is somewhere in the memory, you pass a pointer to that value, so the function now knows where in the memory that value is. and can access it and write to it in case of passing that value, you just pass the value in C++ there's also pass-by-reference, which is similar to pass-by-pointer but more implicit, and there's also constness that should be taken into account
0xJosh
Calculate mean and median temperature - Pastebin.com https://pastebin.com/B9HiNGTm
0xJosh
Guys please help me out on this code. The compiler tell me "Error : request for member 'push_back' in 'temps', which is of non-class type 'double'
0xJosh
And "Error: no matching function for call 'sort(std:: vector<double>&)
0xJosh
🙏 what am I doing wrong
Anonymous
Does anyone knows how to use functions swap in c
Pavel
Guys please help me out on this code. The compiler tell me "Error : request for member 'push_back' in 'temps', which is of non-class type 'double'
When you declare a variable with the same name as another variable in an outer scope, this situation called shadowing. In your case temps refers to double, so you trying to call push_back to a double. To solve this give different names to different variables
Pavel
I mean I haven't looked on all the parts of the code, I just say what that exact error about
0xJosh
Rename variables?
It's not working 😭
0xJosh
Rename variables?
Push_back is not a variable tho. It's a function used to push elements into a vector from the back
Egro
do you guys read any c++ text books? i see a lot of questions here that are explain in text book. like the function "push_back"
Egro
i have a feeling some people learn progamming as they type, not knowing what they are typing
Egro
important to read about the language and how its properties are used and applied, then our self practice what we read
Y'amiGami
Does anyone knows how to use functions swap in c
suppose you wanna swap from a to b. you declare a temporary variable "c" and do c = a then you turn a into b and b into c you have successfully swapped a and b
Anonymous
And "Error: no matching function for call 'sort(std:: vector<double>&)
The algorithm sort doesn't take a container but instead takes a pair of iterators (in the case of C++20, it accepts a range).
Simon
Someone help me to begin learning C++,,
Simon
They are very expensive,kindly can you assist me with a PDF notes for a begginer purposely in C++.
Simon
Someone to help me with various examples of written programs in C ++,eg From Hello World,sum of two numbers,Controls eg if,if else if ,case etc do that I can run them to perfect
0xJosh
do you guys read any c++ text books? i see a lot of questions here that are explain in text book. like the function "push_back"
Yup I'm studying the book "principles and practice using C++ by soustrupp", so pretty much know what the function is
Simon
It have no practice exercise which will help me compile then and run in pc
0xJosh
Do a simple goggle search Like "examples of written program in c++"
Egro
Guys please help me out on this code. The compiler tell me "Error : request for member 'push_back' in 'temps', which is of non-class type 'double'
i think this mean, the variable you define "temp" is not a member of what ever class you have.. i could be wrong, would be better if you post a picture of the source code, so we all may see it and not go off the complier warning.. only syntax error are 100 accurate by complier, others error are base on statistical aggression, which are not 100%, only syntax errors are 100%
George
Guys, I have concerte basics in C language
George
Now looking to start working on C based real application project
George
Any beginner friendly application opensource on github
George
My area of interest is Embedded Programming
Talula
My area of interest is Embedded Programming
Cool... I'm into Embedded Programming...
Sylvester Lim
Abyss Devolos FT1232 Balance Vatryek Wing Accel B9492 Attack if(infile) { while(infile>>*(name+i)>>*(id+i)>>*(type+i)) { i++; } Hi, i want to insert cardName, cardID, and cardType into 3 parallel arrays, but since they are all STRING type, with my code above since card name have space between them, it will be inserted to the next parralel array. I have tried with getline but it will then insert the whole line into the array, which defeats the purpose of wanting to put them into parallel arrays. What can i do ? (No vectors pls) just plain simple arrays , any help is appreciated
Pavel
Push_back is not a variable tho. It's a function used to push elements into a vector from the back
I haven't told to rename push_back, i told you that you have two different variables with the same name "temps"
A
I have a question
A
If i need to store multiple ID for example "A23FF5686", and i want later to store every single one of those id's for later calls
A
How come can i include integer with string in the same id
A
And is it possible to get them all in a single variable
KRYZ
I have a question concerning blockchain programming. Can blockchain be programmed with C(Low Level Programming Language)?
A
I mean the integer and the string in the id
Osoroshi
Hi. Tell me how best to read data from COM Port and then use it?
KRYZ
Yeah I think.
OK thanks
0xJosh
OK thanks
You can check out Ripple. I think they use C
Ибраги́м
https://www.youtube.com/watch?app=desktop&v=ZQFzMfHIxng&feature=youtu.be