Dadaskis
Aaw shit
Francisco
When we pass a vector<int> made in main to a function fun() like fun(vector<int> f){} Then, Is another vector created on heap and copies the element of the called vector into it?
That's passing by value, so a copy of that vector is created (dynamically, because it' allocated in the heap). You may want to pass it by const reference
Artöm
Anyone tell this bug
;;;;; you lost
Anonymous
So, that mean that any changes on f does not change the actual vector?
Anonymous
Also, on return of the function fun(), does the duplicate vector gets destroyed?
Anonymous
or does it persists in memory
Anonymous
Yes
but since it's in heap, who destroys it?
Artöm
Vector object itself
olli
but since it's in heap, who destroys it?
The destructor, once the lifetime of an object with automatic storage duration ends the destructor gets invoked. This is also used by std::unique_ptr to free the memory or lock_guards to unlock the mutex automatically
olli
Any types with dynamic allocation
If an object does not have automatic storage it does not, you need to delete it explicitly. The following leaks void foo() { new std::vector<int>{}; }
MᏫᎻᎯᎷᎷᎬᎠ
The destructor, once the lifetime of an object with automatic storage duration ends the destructor gets invoked. This is also used by std::unique_ptr to free the memory or lock_guards to unlock the mutex automatically
Is it a bad practice to make a shared_ptr - like type of my own Using a counter of reference type?! Like this one in simple code: class shared_ptr { Int& counter; shared_ptr(const shared_ptr& oth){ counter = oth.counter; ~shared_ptr(){ if (counter == 0) { Delete ptr; } } } }; It's easy to track, right?!
MᏫᎻᎯᎷᎷᎬᎠ
How is counter initialized?
Well You want to have another variable called like zero with 0; It's the actual value that is Changed
MᏫᎻᎯᎷᎷᎬᎠ
It is bad. This shared_ptr cant rebind
So We can use ptr type so we can rebind it again to another, right?!
MᏫᎻᎯᎷᎷᎬᎠ
olli
Well You want to have another variable called like zero with 0; It's the actual value that is Changed
the thing is, you basically need two pointer inside your shared_ptr, one is for ref counting and the other one is for the object itself
MᏫᎻᎯᎷᎷᎬᎠ
Ofc, you can't ignore the party crasher
Anonymous
Hii
klimi
Hii
hello
Anonymous
I need help in Cpp
klimi
right group
Dima
right group
the left one
klimi
the left one
what's my title
klimi
none :<
Sid Sun
:(
Dima
Yes it is
klimi
well ... its okay i guess
Sid Sun
well ... its okay i guess
Can we get it changed to something like, segmentation fault lol
Anonymous
To find sum of two integers without using ‘+’ operator.
Roxifλsz 🇱🇹
what's my title
Should I change it to "not a girl"?
Roxifλsz 🇱🇹
Sid Sun
To find sum of two integers without using ‘+’ operator.
Define custom class with a constructor and operator overload '-' to do addition
Dima
operator overlord lol!
klimi
that would decrease my pm rates
Roxifλsz 🇱🇹
that would decrease my pm rates
Aight, I'm doing it
Sid Sun
Aight, I'm doing it
I would like "Operator Overlord"
Sid Sun
😂
Roxifλsz 🇱🇹
I would like "Operator Overlord"
Nicks only come with admin privs
Sid Sun
Nicks only come with admin privs
I indirectly asked for that
Roxifλsz 🇱🇹
I indirectly asked for that
Smooth move, I might consider that
Sid Sun
😂👍
Sid Sun
That's all I ask for 😁
Lionel
Why not an IDE?
Anonymous
i feel like the writers of head first C where real stoners
JCV
hi team just a question, if i have MinGW on MacOS and i compile my project will run on windows right?
Mat
Write the algorithm, not an example 🤷‍♂
Dima
Віталій
Ok😔
Dima
Ok😔
there are russian chats if you need to
Dima
Віталій
I only found one Russian and your second
Dadaskis
@stdvector
You fast
JCV
Is windows the compile target?
yes i wanna to compile on macos for windows!
JCV
not possible
so i need to compile the project on windows
Dadaskis
yes i wanna to compile on macos for windows!
Compile for windows on windows
Mat
https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/
Mat
Maybe this can be helpful 🤔