Thank you for your videos. I was able to use your videos to revise my c++ skills from many years ago to get a job. I would like to add from experience one can go through life as an c++ developer and never have to use friend functions or inheritance...But It's good to know it!!
whats the difference between a "friend function" and "defining a method outside a class definition using the scope resolution operator" as done in one of your other videos?
You can say that when using scope resolution it's just like you'd declare the method publicly inside the class. The difference of a friend function it's that the friend function can be called with other parameters, those that are not exclusive members of the class. So you can use the friend function with global variables and local variables of main, which you cant with the function declared with the scope resolution operator for the class.
Hi Anil Sir, your video was informative. Since you have so many subscribers may I suggest you to be a little careful about indentation. Since, so many people are watching your videos they might pick up not taking code indentation seriously!
Hi Sir, before I watch this video, I were learning OOP from other websites. I find a difference in friend function declaration. In your video, you declare friend function as - friend return type function name (class_name object_name) like " friend void display(Human man)". However, in this following website : www.cplusplus.com/doc/tutorial/inheritance/ The writer declare friend function as - "friend Rectangle duplicate (const Rectangle &)" Therefore, I have 2 questions that I would like to know 1. In friend function declaration, what is the meaning of "&" in the function input argument? 2. In friend function definition, what is the meaning of "Rectangle& param" in the function input argument? Thanks.
ganesh karthi i'm using mingw toolset. checkout this video to download and install codeblocks along with mingw. ua-cam.com/video/MDJ9uEHDhfU/v-deo.html
What you're saying if I'm correct is to use the scope resolution operator to define the function outside the class. In the example shown by this video, you could just do that but realise that friend functions are very useful in operator overloading.
Dire Red if you are asking link for the source code checkout www.learninglad.com/p/cplus-plus-free-video-tutorials.html if you wanna download this video then you have to use any youtube video downloading software's.
Sir I'm having an error in my program: /*Friend Functions*/ #include #include using namespace std; class Human { //private access specification by default, if nothing written string name; int age; public: Human(string iname,int iage) { name = iname; age = iage; }//end constructor void display() { cout
sir I have one doubt. In 18 & 22nd line u declare object name as man but in 30th line the object name is anil. I think "man" is an dummy argument Isn't or not.
ganesh karthi dude, in line 18 n 22 "man" is the function parameter name (which is of type human). anil is the object name in line 30. Here we are calling display() function and passing anil object as argument. inside display() function man will point to anil object. Hope this helps :)
+Yougadha Gupta sorry for late reply. you are missing } for student constructor. #include #include using namespace std; class student{ int id; int marks; public: student(int nid,int nmarks){ id=nid; marks=nmarks; } friend void display(student name); }; void display(student name){ cout
Thank you for your videos. I was able to use your videos to revise my c++ skills from many years ago to get a job. I would like to add from experience one can go through life as an c++ developer and never have to use friend functions or inheritance...But It's good to know it!!
I always smile at the String error 😊🥰....so sweet error...n ur tutorials as usual amazing 🤗💛
😊 thank you
@@LearningLad we shud thank you for taking time for sharing ur knowledge thank you so much sir❤️
a sweet error of String every time 😁😁😁. all videos are great .
I understand c++ only from these videos thank you sooo much sir
...
Thank you.
i'm really glad that my tutorials are helping you :)
Really useful tutorials.... preparing for exams from your channels.
You're a fan of Bucky Roberts.. aren't you?
awesome videos! I thought c++ is difficult but these video cleared all my concepts.
Thank you :)
thanks for this video i am software engener in microsoft usa
Pleasure
AWSOME ! this video helped me to understand friend function properly :D
+Shahriar Rahman
awesome :)
I think so you have the habbit of java that's why everytime making 's' capital 😁 . Your videos are very much helpful for me thanks alot 😊
Glad you like them!
what are you using "void tellme" function for?
Oops, there u r .......😐
Sir,what is the difference between using "friend" keyword and scope resolution operator(::)??
yOU'RE ALWAYS AWESOME
Thank you so much sir ❣️
Most welcome
Even i am following every video and making all the programs in codeblocks
im really glad that my tutorials are helping you :)
Thank you so much, sir
Most welcome
whats the difference between a "friend function" and "defining a method outside a class definition using the scope resolution operator" as done in one of your other videos?
You can say that when using scope resolution it's just like you'd declare the method publicly inside the class. The difference of a friend function it's that the friend function can be called with other parameters, those that are not exclusive members of the class. So you can use the friend function with global variables and local variables of main, which you cant with the function declared with the scope resolution operator for the class.
Hi Anil Sir, your video was informative. Since you have so many subscribers may I suggest you to be a little careful about indentation. Since, so many people are watching your videos they might pick up not taking code indentation seriously!
This is nice tutorial
it would be much better to understand if syntax and definition are added as well.
other wise everything is well.
Thank you for the suggestion.
will consider it for upcoming video's :)
Thank you for the suggestion.
will consider it for upcoming video's :)
Nice Lecture
Thanks :)
In this example, what would be the difference in making setter/getter functions and using this friend function way???
why we have passed anil as a parameter to call display function in main() ????
sir will you take tutions for a large set of students
what is the use of tellme function
As you passed instance of Human as a parameter in a function,so it is not needed to do like (man.diplay()),Is it the way I thought
Are friend classes bidirectional? i.e. both classes can access each others members?
thnx sir
Abhishek Gautam
pleasure man :)
sir here is it mandatory to pass the object ?? instead can v use cal by reference?
awesome videos ;)
Thank you :)
TY
welcome :)
Hi Sir, before I watch this video, I were learning OOP from other websites. I find a difference in friend function declaration. In your video, you declare friend function as - friend return type function name (class_name object_name) like " friend void display(Human man)".
However, in this following website :
www.cplusplus.com/doc/tutorial/inheritance/
The writer declare friend function as - "friend Rectangle duplicate (const Rectangle &)"
Therefore, I have 2 questions that I would like to know
1. In friend function declaration, what is the meaning of "&" in the function input argument?
2. In friend function definition, what is the meaning of "Rectangle& param" in the function input argument?
Thanks.
what compiler u use pls send me the link or just say compiler name sir
ganesh karthi
i'm using mingw toolset.
checkout this video to download and install codeblocks along with mingw.
ua-cam.com/video/MDJ9uEHDhfU/v-deo.html
Anil😍
why do we need to use friend function, why can't we just do scope resolution?
What you're saying if I'm correct is to use the scope resolution operator to define the function outside the class. In the example shown by this video, you could just do that but realise that friend functions are very useful in operator overloading.
Download link pls
Dire Red
if you are asking link for the source code
checkout www.learninglad.com/p/cplus-plus-free-video-tutorials.html
if you wanna download this video then you have to use any youtube video downloading software's.
ty
man is class ??
Human is a class.
man is just an object.
Sir I'm having an error in my program:
/*Friend Functions*/
#include
#include
using namespace std;
class Human
{
//private access specification by default, if nothing written
string name;
int age;
public:
Human(string iname,int iage)
{
name = iname;
age = iage;
}//end constructor
void display()
{
cout
Ur wrote display function wrongly..check once
#include
#include
using namespace std;
class human{
public:
string name="vinay sharma";
friend void display();
};
void display(){
cout
sir I have one doubt. In 18 & 22nd line u declare object name as man but in 30th line the object name is anil. I think "man" is an dummy argument Isn't or not.
ganesh karthi
dude, in line 18 n 22 "man" is the function parameter name (which is of type human).
anil is the object name in line 30.
Here we are calling display() function and passing anil object as argument.
inside display() function man will point to anil object.
Hope this helps :)
*****
thank u very much sir
if we remove friend then we can use anil.display(anil) which will work.
lol
#include
#include
using namespace std;
class student{
int id;
int marks;
public:
student(int nid,int nmarks){
id=nid;
marks=nmarks;
friend void display(student name);
};
void display(student name){
cout
+Yougadha Gupta
sorry for late reply.
you are missing } for student constructor.
#include
#include
using namespace std;
class student{
int id;
int marks;
public:
student(int nid,int nmarks){
id=nid;
marks=nmarks;
}
friend void display(student name);
};
void display(student name){
cout
cant yu even check out what the errors are.. ~-~
Well tried !