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

C program for reverse the word in string, C Program for REVERSE THE WORD IN...

C Program for REVERSE THE WORD IN STRING #include conio.h> #include stdio.h> #include string.h> void main() {           char a[50],b[25][25],temp;           i

Matlab assignmnet, I have a Matlab assignment and I have the assignment des...

I have a Matlab assignment and I have the assignment description+ algorithm + and the output sample. the files are on a dropbox folder and you can download them from the link below

Last fibonnaci standing, i need a program for finding the last fibonacci nu...

i need a program for finding the last fibonacci number

The square roots of the integers from 1 to 100, Assume we wish to partition...

Assume we wish to partition the square roots of the integers from 1 to 100 in to two piles of fifty numbers every, such that the sum of the numbers in the first pile is as close as

Library functions, is getchar() is a C++ library function?

is getchar() is a C++ library function?

C, how to learn programming skills

how to learn programming skills

What does throw; (with no exception object after the throw , What does thro...

What does throw; (with no exception object after the throw keyword) mean? Where would I employ it? A: You should see code that looks something like this: class MyException

Gaming tracks company for a mobile game developing, We want Guys For Job in...

We want Guys For Job in Gaming Tracks Company for a mobile game developing Project Description: I want a team of game developers for life-time as mobile dev team in my compan

Decode the code, Smugglers are becoming very smart day by day. Now they hav...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Object oriented programming and cryptography, This assignment document will...

This assignment document will be distributed from Blackboard assignment folder. Some parts of the assignments will require you to research answers from your text book (you must rea

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