Always Please upload these kind of video's.If any new concepts come in C++ or if any old concepts you was forgot to take means please take that lecture and upload it because always I have followed your series
Thank you so much for your explanation sir!!!, This working fine with "set" , If I am doing similar for " vector" using push_back and emplace_back. both constructor & copy constructor are getting called that to If I use both same time. int main() { vector v; v.push_back(A(10)); v.emplace_back(10); // using push_back & emplace_back at same time will lead calls to constructor and copy constructor for emplace_back return 0;
} If I use alone its working as expected like set. why sir ?
In latest version of msvc what I have observed is that if you call push_back also. It internally calls emplace_back. So that objects can be constructed implace only. Correct me if i am wrong.
@@CppNuts When I was using vec.push_back() I tried to navigate into push_back method through which i come to know that internally it calls emplace only.
A property of a set is that all elements within the set is unique -- they don't compare "equal". Because std::set is templated and can contain anything, including the user-defined class A in this video, you must tell the set how to compare two type A objects. You'd think you'd do this by overloading the == operator but actually, you have to overload the < operator. You can define equality in terms of
@6:19 can you please shed some light on why inside for loop u wrote those lines? under what topic they come? Is it part of iterators used with stl or something else?
It's "range for" operator denoted by : This can be used on any containers that has begin and end methods. This is usually used instead of conventional for loop where we have int i
While inserting in SET if our data type is user defined then we need compare function which will be called automatically so that SET data structure can decide which object is smaller and which on is bigger.
Even i am waiting for that time, my timings are messed-up, too much of office work. Now i am able to breath, you can expect it soon. Sorry to keep you waiting dude.
Line 19 I tried to put it inside the class's definition like: class {... bool operator < (const A& rhs) { return this->x < rhs.x; } } Doesn't work. Only works with operator +=, ++, - -
Best ever c++ channel,Hope you reach 100K soon, Best Wishes
Thank you so much 😀
Very beautiful explaination sir.
Thanks man!
Always Please upload these kind of video's.If any new concepts come in C++ or if any old concepts you was forgot to take means please take that lecture and upload it because always I have followed your series
Sure man!!
Thank you so much for your explanation sir!!!,
This working fine with "set" , If I am doing similar for " vector" using push_back and emplace_back. both constructor & copy constructor are getting called that to If I use both same time.
int main()
{
vector v;
v.push_back(A(10));
v.emplace_back(10); // using push_back & emplace_back at same time will lead calls to constructor and copy constructor for emplace_back
return 0;
}
If I use alone its working as expected like set. why sir ?
In latest version of msvc what I have observed is that if you call push_back also. It internally calls emplace_back. So that objects can be constructed implace only.
Correct me if i am wrong.
Not sure about this man!!
How do you know this is the behavior?
@@CppNuts
When I was using vec.push_back()
I tried to navigate into push_back method through which i come to know that internally it calls emplace only.
Ankit bro can u explain me 15 n 16 th line ..I didn't get as I am new to CPP
Thanks
@@behindthescene4406 15 th line is a constructor , but 16 i don't have any idea .. 🤔is it a destructor .. nope !
@@chaithanyareddy5855 the 16th line is a copy constructor.
Any particular reason, why operator function (
A property of a set is that all elements within the set is unique -- they don't compare "equal". Because std::set is templated and can contain anything, including the user-defined class A in this video, you must tell the set how to compare two type A objects. You'd think you'd do this by overloading the == operator but actually, you have to overload the < operator.
You can define equality in terms of
i had to write < inside the class def , and also make it friend ..otherwise it wasnt compiling
while defining constructor in line no.15, why did u use x{x},please explain...
Same doubt
same
That's shortcut to put values
It initialize x
Great work friend, its really awesome, keep it up!
Thank you, I will
Really Great Explanation !! ❤❤❤
Glad you liked it!
sir if possible can u please explain the constructor syntax used. both first and second one plz sir plx
Sir pls make a video on bool operator . I am little confuse while using this operator.
sir, do we have videos on move semantics , move constructor or RValue Reference ?
Forgot these topics, will cover sometime later.
Bro I didn't understand the comparison function can u plz explain it to me
@6:19 can you please shed some light on why inside for loop u wrote those lines? under what topic they come? Is it part of iterators used with stl or something else?
It's "range for" operator denoted by :
This can be used on any containers that has begin and end methods.
This is usually used instead of conventional for loop where we have int i
Also, Here he used to display contents of every object of class A in set
wouldnt it also with with Set.insert(2) because you have a constructor that takes 1 int without explicit declaration, so it does implict conversion
what is the role of code in line number 19????
what is bool return type returning here
detailed explanation plz
While inserting in SET if our data type is user defined then we need compare function which will be called automatically so that SET data structure can decide which object is smaller and which on is bigger.
Would like to hear "template meta programming" from you
Sure man..
God You;
Thanks dude..
Can you please explain why copy contructor is called without being called?
You don't see it when u write code, but when compilation happen then so much of new code is injected. And that time explicit call will be there.
what is the purpose of the &rhs ans &lhs , im a beginner ,dont mind ,please help me out.
Could you make Datastructure tutorial fast..I was waiting for it
Even i am waiting for that time, my timings are messed-up, too much of office work.
Now i am able to breath, you can expect it soon.
Sorry to keep you waiting dude.
what is this way of using Constructors called? A(int x=0):x{x}{}; and how do we set multiple members in this way?
Amazing
Line 19 I tried to put it inside the class's definition like:
class
{...
bool operator < (const A& rhs)
{
return this->x < rhs.x;
}
}
Doesn't work. Only works with operator +=, ++, - -
What if class has multiple member variable
How this can be used in std::map ?
It similar, just pass key, value in emplace funtion.
@@CppNuts But we use make_pair func to pass object in insert func ..can you show by one line example?
Map.emplace(key,value);
Great! 😍
The best ♥️♥️
Thanks..
This's can't help ! SORRY for this comment!
Sorry