6:40 -> It will show an error because "Y" should be forward declared. It should be declared before defining the class "X". 15:17 -> It will not show any error. 16:55 -> Values will not swap if "&" is removed.
One thing I would like to suggest as your student, Before explaining any topic using an example, try to explain the example question first so that we could also get some idea what the use of this topic and get more interest in the topic...😁 Otherwise, all ur content is just awesome❤❤
pehle 2 vedios me friend function bohot hard lgg raha tha lekin jbb is vedio ko dhekha to Friends function 💯% msj gaya... Harry bhai aapne iss vedio me jese examples liye he smjane ko ... vese hi Simple examples liya karo pahle... agar aapne ye wale examples pahle 2 vedios me samjaya hota to iss vedio ki koi jarurat nahi thi .... By the way Thank you Harry Bhai... This tutorias playlistl help me a lot of information in C++;
Hey harry, I have written the code wherein I took input from the user in two different classes, then added the numbers and printed their result using a common friend function as you instructed in the video. positive and constructive feedback is always welcomed. code: #include using namespace std; // forward declaration of the classes to avoid any unecesaary error. class input1; class input2; // input1 : first test class in place of X. class input1 { int x; public: void setdata(int a); friend void add(input1 a, input2 b); }; // setdata() of input1: to set the value of x to be equal to a void input1 :: setdata(int a){ x = a; } // input2: second test class in place of Y. class input2 { int y; public: void setdata(int b); friend void add(input1 a, input2 b); }; // setdata() of input2: to set the value of x to be equal to a void input2 :: setdata(int b){ y = b; } //common friend function to both the above classes void add(input1 a, input2 b){ cout
16:49 No, values will not be swapped. Then only pass by value will occur and change in values of formal parameters will not be reflected in actual parameters
challenge aceepted [16:49]----> the value will not be swapped becoz the value given by you will go to first in c1 and c2 class as parameter there the friend function exchange would be there which exchange the value but that would not be shown in main function
For swapping, Call by reference or call by pointer can also be used there but in case of call by pointer we need to use arrow operator instead of dot operator to access members of objects and dot operator could also be used but for that we need to use parenthesis like👉🏻(*ptr).member_name to access members of the objects.
14:28 becoz we've not written friend function in both the class and also after writing the friend function we have to give forward declaration of class c2
6:30 yes it will give error as class Y is declared afterwards and compiler won't be able to access it while it is still in the class X . 17:00 it will not swap
17:10 -> the values will not get exchanged as the removal of '&' operator makes the function call by value. Where the copies of object parameters are made
17:08 the values here won't swap because you explained in the reference variables video that it will just copy the value. That's why the values won't swap.
can you create live sessions for this ? you are the teacher who understand what student thinking about doubt virtually. A lot of students watch your videos to clear their doubt. there is 0.000000000001% possibility those students who are in computer engineering field don't know you. Keep going
6:28 @CodeWithHarry Yes! this program will throw error because, while going through the code `friend int add(X o1, Y o2);` in class X, the compiler will ask ---- "what the heck is this class Y? never heard of it!" --- In short, we need a forward declaration of class Y before defining class X to remove that error. 15:17 @CodeWithHarry Nahi ji koi error nahi aaega! 16:49 @CodeWithHarry Ji nahi values swap nahi hongi. Thank you for your lectures and sincere effort to help people like us😊
This is the best video I have ever seen Harry Bhai... Thank you very very much... The example of permission taken by android app is the best example.. I think anyone who are watching this video carefully will never forget about friend functions.
16:57 The value will not swap because we Removed the '&' and it means that we are taking the parameters in call by value and in call by value we cannot change the actual value .
6:46-> Ye error show krega kyuki Y ko phle declare krna chahiye tha 15:12 : No it will not show any error 17:02 : Nahi values swap nhi hongi agar & hata diya toh
challenge accepted :time[14:03]--> "Error is comming becoz we cant access private data from outside function which is exchange.....(Solution) --> so here we would use Friend function.
In my opinion, the values of val1 and val2 will not swapped if we do not used '&' since the reference to the memory location of the variables val1 and val2 will still be the same. Thus, we should not be having any swapped values.
1st qstn answer..forward declaration of Y... 2nd answer....no error will come as you have made a friend function 3rd answer....no swap as we are swapping by call by value so whatever changes we made will not be reflected into actual args...
6:18 we have to declare class Y; before class X because we are using object Y in the function(where we declared add as friend ) inside X values swap nahi hogi kyonki function end hota hai to all argument will get destroyed
If we remove ambpercent values will swap Inside fxn but the changes didn't reflect back in main fxn.#call by value.😁 I think so if I am correct then Harry bhai give heart else comnt me and correct my mistake. Pls
16:56 Values will Not get swapped. Since we have passed Copies of values inside the variable; and not variable(or address of var using pointer) itself.
6:39 Yes it will throw an error because there is no forward declaration of the class y which is being used in class x inside declaring friend function.
Without using reference variable(&) the value is exchanging #include using namespace std; class c2; class c1{ int value1; friend void swapped(c1,c2); public: void setdata(int num1){ value1=num1; } void display(){ cout
yes it will produce a error resign: when a compiler start compiling the code it will start compiling from first line of code and it firstly read class X and inside the class X there is friend function declared (friend void add(x , y)) in this case compiler alraidy knows what is means on X in declaration of friend function but it still not know what is Y. solution: To solve the error make a pre-declaration of class Y
6:30 no errors because now all private part of X and Y can be accessed 15:27 no errors 16:57 no swap since there is no direct relationship they just passed the value
6:40 -> It will show an error because "Y" should be forward declared. It should be declared before defining the class "X".
15:17 -> It will not show any error.
16:55 -> Values will not swap if "&" is removed.
7:18 oh yes i forgot that the compiler doesnt know Y yet. now i will remember. Thanks Harry bhai!
Bhai tera name Ishan pandita hai wo football player
@@Mumbai_indians-11 bhai tujhe kaise pata iska naam
One thing I would like to suggest as your student,
Before explaining any topic using an example, try to explain the example question first so that we could also get some idea what the use of this topic and get more interest in the topic...😁
Otherwise, all ur content is just awesome❤❤
pehle 2 vedios me friend function bohot hard lgg raha tha lekin jbb is vedio ko dhekha to Friends function 💯% msj gaya...
Harry bhai aapne iss vedio me jese examples liye he smjane ko ... vese hi Simple examples liya karo pahle...
agar aapne ye wale examples pahle 2 vedios me samjaya hota to iss vedio ki koi jarurat nahi thi ....
By the way Thank you Harry Bhai...
This tutorias playlistl help me a lot of information in C++;
8:01 Thanks for giving simplest example of friend function ❤❤
Hey harry, I have written the code wherein I took input from the user in two different classes, then added the numbers and printed their result using a common friend function as you instructed in the video. positive and constructive feedback is always welcomed.
code:
#include
using namespace std;
// forward declaration of the classes to avoid any unecesaary error.
class input1;
class input2;
// input1 : first test class in place of X.
class input1 {
int x;
public:
void setdata(int a);
friend void add(input1 a, input2 b);
};
// setdata() of input1: to set the value of x to be equal to a
void input1 :: setdata(int a){
x = a;
}
// input2: second test class in place of Y.
class input2 {
int y;
public:
void setdata(int b);
friend void add(input1 a, input2 b);
};
// setdata() of input2: to set the value of x to be equal to a
void input2 :: setdata(int b){
y = b;
}
//common friend function to both the above classes
void add(input1 a, input2 b){
cout
16:54
No values will not be swap because it's Call by value. In call by value function won't return the value thta's why values won't be swap.
Harry bhai you are a very hard working guy, respect!
16:49 No, values will not be swapped. Then only pass by value will occur and change in values of formal parameters will not be reflected in actual parameters
Thanks very much
I am in 7th grade and i have learned many languages from you
You are the best
Same to you
challenge aceepted [16:49]----> the value will not be swapped becoz the value given by you will go to first in c1 and c2 class as parameter there the friend function exchange would be there which exchange the value but that would not be shown in main function
For swapping, Call by reference or call by pointer can also be used there but in case of call by pointer we need to use arrow operator instead of dot operator to access members of objects and dot operator could also be used but for that we need to use parenthesis like👉🏻(*ptr).member_name to access members of the objects.
if we do the same in java or python then how
@@DSMAHarshSingh Java and python don't support pointers
I just learned from Jenny Ma'am ❣️
// Always forward declaration
class Y;
class X
{
public:
int data;
void setValue(int value)
{
data = value;
}
friend void add(X, Y);
};
class Y
{
public:
int num;
void setValue(int value)
{
num = value;
}
friend void add(X, Y);
}; --> 6:42
17:18 > Value won't be swap as because function always passes a copy in general , but referencing will swap it as because they got their address
You're such a great teacher sir..❤
6:35 there will be error because class Y should be forward decleared.
15:14 no error
16:56 vlaues swap nai hogaa
poor harry wanted 3 separate comments :(
17:16 Values will not swap :- u will have to use call by reference either pointer or reference variables
Thank you sir for this great explanation ❤ everything is easy because of you ❤️ 19:14
14:28 becoz we've not written friend function in both the class and also after writing the friend function we have to give forward declaration of class c2
6:46 yes it will throw error as when compiling the line no. 19 the compiler will say what is y so we have to forward declare y before x
6:30 yes it will give error as class Y is declared afterwards and compiler won't be able to access it while it is still in the class X .
17:00 it will not swap
In which video he taught about string or reversing of number ?
This is one of the easiest tutorials in this video playlist
17:10 -> the values will not get exchanged as the removal of '&' operator makes the function call by value. Where the copies of object parameters are made
6:28 yes, error throw krega . Kyuki uper friend function declare krte time usme Y bhi h to pahle Y class ko define krna padega
17:09 Values wont be swapped because the function cannot change the actual value of the driver function , Instead it just makes a copy of the value.
6:36 This program will throw an error because of not declaring it as a forward declaration.
15:00 This will not throw any error.
06:31 yes it will as we havent declared y and are using it in function so it will
Harry bhai, mai bhi appke jaise hardworking hu, mai bhi sab bahot jaldi seekh jata hu. Thanks for reading this
17:10 values will not swap because copy of actual parametrs has passed there will be no change in actual parameters...
Bro ur examples are god damn funny but for easy to understand.Bcz of i can easily learn C++.
Huge respect to u.......
Thankyou Harry for this video the concept of friend function and friend class was really clear
bhai main kabhi kabhi itna aalsi ho jata hun ki aapna pur asource code hi copy kar leta hun . Love your teaching style harry bhai
17:08 the values here won't swap because you explained in the reference variables video that it will just copy the value. That's why the values won't swap.
6:45 yes it will throw the error because the compiler doesn't know the class Y
[17:12] The values will not be swapped as only an instance of an object will be passed and not the object
can you create live sessions for this ?
you are the teacher who understand what student thinking about doubt virtually.
A lot of students watch your videos to clear their doubt.
there is 0.000000000001% possibility those students who are in computer engineering field don't know you.
Keep going
jarurat nahi hai
@@MrDoge-td7mj laude tuzhe nahi bola vo
6:40 cause we have to declare class Y before X to tell compiler that when u execute class Y will come somewhere in the program
6:28 @CodeWithHarry Yes! this program will throw error because, while going through the code `friend int add(X o1, Y o2);` in class X, the compiler will ask ---- "what the heck is this class Y? never heard of it!" --- In short, we need a forward declaration of class Y before defining class X to remove that error.
15:17 @CodeWithHarry Nahi ji koi error nahi aaega!
16:49 @CodeWithHarry Ji nahi values swap nahi hongi.
Thank you for your lectures and sincere effort to help people like us😊
16:52 No, as those variables will be of same name but different address, so It wont affect the arguments
This is the best video I have ever seen Harry Bhai... Thank you very very much... The example of permission taken by android app is the best example.. I think anyone who are watching this video carefully will never forget about friend functions.
How is code with Harry after you learned whole c++ language?
yes because friend void add(x o1,y o2) yah par compiler ko y class ke baare me pata nahi hai; first we declare class y;
and use it
But kia Hum class y k Liye forward declaration ni krein ge? Q k use Bhi X ka ni pata...to hum kia class X ni likhein ge??class y me forward to k Liye
17:20 nhi hongi swap because call by value hota hai basically it copies the value first and then swaps it
16:57
The value will not swap because we Removed the '&' and it means that we are taking the parameters in call by value and in call by value we cannot change the actual value .
The swapping method name is BUBBLE SORT ALGORITHM, LEARNED THIS IN MY A LEVELS
6:46-> Ye error show krega kyuki Y ko phle declare krna chahiye tha
15:12 : No it will not show any error
17:02 : Nahi values swap nhi hongi agar & hata diya toh
challenge accepted :time[14:03]--> "Error is comming becoz we cant access private data from outside function which is exchange.....(Solution) --> so here we would use Friend function.
In my opinion, the values of val1 and val2 will not swapped if we do not used '&' since the reference to the memory location of the variables val1 and val2 will still be the same. Thus, we should not be having any swapped values.
1st qstn answer..forward declaration of Y...
2nd answer....no error will come as you have made a friend function
3rd answer....no swap as we are swapping by call by value so whatever changes we made will not be reflected into actual args...
6:40 yes y ka forward declaration Karna padega
17:00 values exchange nhi hogi because value ki copy pass hogi address/reference nhi!
16:46
no the values will not swap because we want to give reference
without reference the value will not swap
6:41 yes it will throw error as there should be a forward declaration of class Y before class X.
6:18 we have to declare class Y; before class X because we are using object Y in the function(where we declared add as friend ) inside X
values swap nahi hogi
kyonki function end hota hai to all argument will get destroyed
17:08 --> it won't work since the arguments are just a copy of the actual values, so the numbers won't swap
17:06 no swapping of values happens because the actual parameters were not exchanged
Your teaching skills are fabulous
If we remove ambpercent values will swap Inside fxn but the changes didn't reflect back in main fxn.#call by value.😁 I think so if I am correct then Harry bhai give heart else comnt me and correct my mistake. Pls
best ever videos on OOP ...
18:56 Thanks bro!!!!
Now after this 3rd video I am 100% clear on Friend function, Thankss a Lott!!!
Jab Harry bhaiya padhaye to complex example bhi simple lagta hai😍🤗
17:07 Without '&' operator the values will not swap.
16:57 / 19:29
The value will not swap.
16:56 Values will Not get swapped. Since we have passed Copies of values inside the variable; and not variable(or address of var using pointer) itself.
class Y ko forward declaration krna padega
To krna
@@shankarshankar5298 Tara do hat Kiya Kam pa laga ha tuuuu kor naa
Best bhai
I Have watched all your videos 2 - 3 times
6:43 Compiler does not know the existence of Y in class X when declaring friend function, hence we need to forward declare class Y; before class X
Sir ap c language and c++ ko aur deep me bhi sikhaoo naa please because ur teaching style is excellent. And every word is understandable.
Very helpful video sir 🙏🙇
14:01 The error is coming because the display function has cout statement in its defination. So no need of cout again for printing the exchange value
06:30 class Y ka prototype declaration karna hoga(forward declaration)
Thank bhai yeh video ne mera friend ka concept clear kr diya ,thanks harry bhai
this is better example than last two videos example
16:50 actual values swap nahi honge bas exchange function me formal value copy hogi aur voh change hogi
6:32 it would throw an error because Y class is not defined above
Thank you very much aise hi aur best videos banate rahiye hum students ke liye
16:15 swap nahi hoga, kyuki it is call by value. Aapne c lang ke vdo me bataya tha
KEEP UP THE GOOD WORK BUDDY !! HOPE YOU A GET A MILLION subs. SOON.......
16:54 values will not swap because call by value is used;
6:28 / 19:29
This program will throw an error.
Thank you harry sir
Error
13:56 Friend function not called; hence exchange cannot access the private members of c1 and c2.
15:26 No Error
Thank you sir I understand perfectly.
In this video I answerd all of question ( in my head) but harry vai deserved the thank you cus i learned from your videos
15:28 - iska matlab friend function ko read/write dono ka access mil jayega class variables ka!
harry you didn't explain operator overloading in this playlist
6:39
Yes it will throw an error because there is no forward declaration of the class y which is being used in class x inside declaring friend function.
Which cource did you chose
Harry bahi this is very good lecture series I learn a lot from this
Thank you harry bhai you are doing great work and you will reach 4 million soon Inshallah
Without using reference variable(&) the value is exchanging
#include
using namespace std;
class c2;
class c1{
int value1;
friend void swapped(c1,c2);
public:
void setdata(int num1){
value1=num1;
}
void display(){
cout
17:06 No the values will not swap after removing the referencing operator.
Time : 17:3
The value is not swap because vales are not exchange , address is changed
amazingg sir!!!!
harry bhaiya you are great saviour.
6:27 yes error aayegaa... kyunki Y class ko declare nai kiye hai pehle... X class ke andar Y ke baare me baate ho rahi hai
17:02 nhi exchange hogi value because address ( &
)ke bina aap value change nhi kr sakte ji
yes it will produce a error
resign: when a compiler start compiling the code it will start compiling from first line of code and it firstly read class X and inside the class X there is friend function declared (friend void add(x , y)) in this case compiler alraidy knows what is means on X in declaration of friend function but it still not know what is Y.
solution: To solve the error make a pre-declaration of class Y
6:30 no errors because now all private part of X and Y can be accessed
15:27 no errors
16:57 no swap since there is no direct relationship they just passed the value
I missed the forward declaration 😭
6:35 shows an error
15:15 no error
16:55 not swap, because it is pass by value not by reference
16:55 obviously swap nahi hoga. Aapne rohan ko apne notes ki copy jo di hai, original thode hi diya.
We love you harry bhai….❤
6:32:00 yes it will throw error i think. because of inaccesibility