Should my class declare a friend function or member function, C/C++ Programming

Assignment Help:

A: Use a member while you can and a friend when you need to.

Sometimes friends are better syntactically (e.g., in class Fred, friend functions let the Fred parameter to be second, whereas members require it to be first). Another good employ of friend functions are the binary infix arithmetic operators. For example :-  a Complex + a Complex must be defined as a friend instead of a member if you wish to allow a Float + a Complex as well (member functions don't let promotion of the left hand argument, as that would modify the class of the object it is the recipient of the member function invocation).

In other cases, select a member function on a friend function.

 


Related Discussions:- Should my class declare a friend function or member function

What is function overloading, Question 1 What is function overloading? Wri...

Question 1 What is function overloading? Write a c++ program to implement a function overloaded Question 2 Explain about the constructors and Destructors with suitable exampl

#pointers, what is the purpose of pointer ? what is the syntax? how it work...

what is the purpose of pointer ? what is the syntax? how it works?

#area under curve, #Write a program to find the area under the curve y = f(...

#Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.   #include float start_poi

Homework, 5 questions. plus i will provide the "vector.h" for the questions...

5 questions. plus i will provide the "vector.h" for the questions that needs it

How to write program, how to write a program for all the types of beam reac...

how to write a program for all the types of beam reactions

LOOPS, HOW CAN WE EASLY LEARN C++

HOW CAN WE EASLY LEARN C++

Define variable declaration in c++, Variable Declaration This declarati...

Variable Declaration This declaration of variables in the C language is permitted only in the starting of their block, prior to executable program statements. In C++ declaratio

Demo assignment, Please send me demo assignment,I want work

Please send me demo assignment,I want work

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd