Sasuke
Yeah
Then first you have to store it in a variable
Twenty19TEight
Then first you have to store it in a variable
But when I initiate the variable with default values then I don't need a variable bro why
Sasuke
But when I initiate the variable with default values then I don't need a variable bro why
Because when you are using default values you are passing a literal. You can also do this t1.setname("Dave") because Dave is a literal here but since you want input from a user you have to store that input somewhere in the memory so that you can use it later on.
Sasuke
so in my case what do I need to fix ?
Store the input in a variable and call the setname function with that godamm variable
Twenty19TEight
And also I actually declared a variable named "name" inside the class
Sasuke
And also I actually declared a variable named "name" inside the class
It's nothing to do out of the class don't worry about it
Twenty19TEight
okay bro I'll try it and let u know abt it
Kenny
Test t1; t1.setName(input);
Twenty19TEight
Thank You Bro!
Kenny
👍
Anonymous
Q3. Write a program for shopping mall, In shopping mall, there is a mobile shop, in this mobile shop you are getting offer if you will purchase mobile phone with power bank you will get 10% discount, but if you purchase any mobile or power bank you will get only 5 % discount. Display this offer to the user screen whenever user is selecting the option. Apply the concept of logical AND and OR operator overloading. Select option: 1. Only mobile 2. Only power bank 3. mobile with power bank 4. no any
Anonymous
Please solve this
Anonymous
Yes report to admin
Mar!o
Please solve this
We are not here to solve your homework fool
Anonymous
We are not here to solve your homework fool
Can u send urs email I show u some magic
Anonymous
Harsha [M]
Can u send urs email I show u some magic
Lol bombing shit? Don’t oversmart
Mar!o
Let see who is fool😌
You are learning basics so stfu
Mar!o
Roxifλsz 🇱🇹
Thanks
I'm just a jannie after all, cleaning up the shit that these people pour into this group
Roxifλsz 🇱🇹
Mar!o
xD
Anonymous
What can be discussed in this group?
Anonymous
What can be discussed in this group?
"When are u" coming to start a discussion Xu
olli
What can be discussed in this group?
see the rules, C, C++, ASM
Anonymous
OK,thank you.
Harsha [M]
!report unknown file
V01D
To the question about new vs malloc / delete vs free. Is it better to use free instead of delete to the pointer I reallocated just before?
malloc is created on the stack (I think!) What I DO know is that new and delete are using the heap, which is actually safer
Vlad
Ammar
malloc is created on the stack (I think!) What I DO know is that new and delete are using the heap, which is actually safer
> malloc allocates memory on the heap, not stack. > Your local variables, env variables, program argv/argc are on the stack.
Don Peter Joseph
Can I make a dynamic memory allocation of a structure without pointer.
V01D
Can I make a dynamic memory allocation of a structure without pointer.
Size_t m = malloc(sizeof(struct name) * 9); I have NO IDEA if this is good or not.
V01D
I know nothing about memory management in C 😂
Vlad
int& p2 = *(new int);
That's gonna be three hundred bucks
V01D
Rip
V01D
Nononono wtf
What is wrong about it
Vlad
What is wrong about it
casting pointer to int isn't enough?)
Ammar
Size_t m = malloc(sizeof(struct name) * 9); I have NO IDEA if this is good or not.
It works, basically pointer is just an integer. But in that case, when you dereference (or use the allocated memory) you will still have to cast it to corresponding pointer type. There is no reason to avoid pointer. If we see at lower level, load everything from memory will involve memory address which is the pointer. Even for static allocation too.
Ammar
It would be better to use uintptr_t I think.
V01D
Thanks
Anonymous
It would be better to use uintptr_t I think.
Oh i actually didn't know that you could cast back from uintptr_t to void *
Anonymous
Nononono wtf
Correction - This is still a problem, but not "Nononono wtf" level
Ammar
Oh i actually didn't know that you could cast back from uintptr_t to void *
Yeah we can. For example in 64 bit environment (where the pointer is 64 bit integer), we can also cast uint64_t to void * or other pointer types. However, uintptr_t is the way to guarantee that is always fit for pointer representation size.
Andrew
I know nothing about memory management in C 😂
You lier , before you answered more complex question 😂
V01D
It is good
You sure? Others said the size_t was wrong
Bojan_Krdemn
hey, who knows algorithms, recursion well here?
V01D
Ah okay. Thanks
Bojan_Krdemn
https://pastebin.com/mrhq4YNw there is an error in recursion / backtracking here but i can't find it. can anybody help?
Andrew
Really? Which one?
no was wrong sorry
Артём
So why not realloc? It does the similar job, and even better, because it's, say, more low-level, than new and copying/moving data.
Anonymous
So why not realloc? It does the similar job, and even better, because it's, say, more low-level, than new and copying/moving data.
Because an object may have a state and, in general, is more than just the underlying memory.
Артём
Anonymous
what did you mean under "may have a state" ?
Anything that the copy/move constructor would handle while realloc() won't
Muhamadxon
Hi for every one. Which GUI framework is the best. For Cpp yeah
V01D
So is malloc or new better? 🤔
Parra
what construction removes the need of using new in 17?
V01D
Alright thanks
Parra
but that applies to 11 too, no?
Parra
oh, got you now
Alex
I am not sure about never