Patrick
How can I use std::string in GDB?
Patrick
Guy
I don't think it's a thing
Patrick
Alright. Well, I have another issue actually
Patrick
in GDB after this line:
void* sPtr = new std::string("hello");
Doing
x/s sPtr
Results in garbage. I'd like to declare a std::string on the heap, referenced in a void*, but it isn't working.
Guy
it's because std::string encapsulates many other things (http://www.cplusplus.com/reference/string/string/ )
Guy
when you use x/s sPtr you actually just try to read characters from that address until you reach a nullbyte.
https://stackoverflow.com/questions/6776961/how-to-inspect-stdstring-in-gdb-with-no-source-code
Patrick
So I should use c_str
Patrick
but I can't cast my void* to std::string in GDB
Guy
anyways google it, I'm sure many others have encountered this specific issues
︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎
Appiah Kumah
hello friends, please i need your help to solve a c++ problem. i have try but not getting it.
Appiah Kumah
questions
A company want to transmit data over the telephone but is concerned that its phones could be tapped. All of the data are transmitted as two-digit integers.
The company has asked you to write a program that encrypts the data so that it can be transmitted more securely.
Your program should read a two-digit integer and encrypt it as follows:
Replace each by ( the digit plus 7) and modulus 10).
Then, swap the first digit with the second and print out the encrypted integer.
Appiah Kumah
Harsh
Appiah Kumah
Harsh
Appiah Kumah
Welcome mate 👊🏿
Please, am using c++ to code it. Please, can u guide me..please?
Appiah Kumah
Ok...thanks
Anonymous
Appiah Kumah
What about this?
Write a program that displays the recommended weight in kilograms, given the user's age and height in centimeters. The formula for calculating the recommended weight is: Recommended=(height-100+ age%10) * 0.90.
Harsh
Appiah Kumah
Should I give the user my own figure or ask for it, please.
Indolent
pastebin.com/hBs37hvL
Indolent
Can anyone explain to me what's happening in this code?
Harsh
Appiah Kumah
Indolent
Anyone?
Artöm
Artöm
Theres no pair in that code
Anonymous
If two sub classes with some same functions is there a way to prevent code duplication?
Artöm
Make base class inbetween, move common functions there
Anonymous
Can someone explain why is line 22 wrong?
Artöm
Why do you think its wrong?
Anonymous
Oh thats cause no operator matches the operands 👍🏼
Alex
add operator or use function in B class for comparison
Artöm
Show full code
Artöm
I see < above and wonder if it is related
Alex
Anonymous
Artöm
mark operator< as const
Artöm
Or make it a free function
Anonymous
👍🏼👍🏼
Alex
free function is not the option, cause he uses n field
Artöm
He can make it friend
Alex
I don`t think its good idea. because of encapsulation violation
Artöm
Friend for comparison operators is always a good idea
Artöm
Hidden friend is even better
Alex
what are pros for this approach?
Alex
what is hidden friend?
Artöm
Artöm
It is a function which is only callable via adl
Alex
I can`t understand your idea. please refer to std lib. operator functions are member of a class or free function. no friends
Alex
except when it have to be friend, like operator«
Artöm
Artöm
Eg these https://en.cppreference.com/w/cpp/filesystem/path/operator_cmp are required to be implemented as hidden friends
Artöm
To avoid unwanted overload candidates
Alex
Artöm
Anonymous
Is there a good website that explains about functor?
Alex
functor is everything which can be called using ()
Chirag
/get cbook
Anonymous
/get
Anonymous
Ok
Anonymous
Chirag
/get best-book
Chirag
/get india
Wisenky
Guys I have a question , Is working on machine learning or something like that is really hard on cpp ?
Wisenky
Im glad to hear that
Wisenky
Lol
Wisenky
Where can I start to learn these facts for cpp , most of the documents based python
Wisenky
I'm student so asking this and thanks a lot guys