answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: Write down a program with Passing object to friend function?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Function to translate source program to object program?

computer


What is the difference between constructor and friend function in c plus plus?

A constructor is a method that fires when the object is instantiated. A friend function is a function that has special access to the object. They are two different types of things, and cannot be further differenced.


Explain the advantages and disadvantages of friend functions?

by: THE DJ AKwww.the-dj-ak.webs.comwww.thedjak.co.nrwww.thedjak.webs.comWhat is a Friend Function?A friend function is a special function in c++ which inspite of not being member fuctionof a class has privalage to access private and protected data of a class.A friend function is a non member function of a class, that is declared as a friend usingthe keyword "friend" inside the class. By declaring a function as a friend, all the accesspermissions are given to the function.A friend function is used for accessing the non-public members of a class.A class can allow non-member functions and other classes to access its ownprivate data, by making them friends. Thus, a friend function is an ordinaryfunction or a member of another class.Need for Friend Function:As discussed in the earlier sections on access specifiers, when a datais declared as private inside a class, then it is not accessible from outsidethe class. A function that is not a member or an external class will notbe able to access the private data. A programmer may have a situation wherehe or she would need to access private data from non-member functions andexternal classes. For handling such cases, the concept of Friend functionsis a useful tool.How to define and use Friend Function in C++:The friend function is written as any other normal function, exceptthe function declaration of these functions is preceded with the keywordfriend. The friend function must have the class to which it is declared asfriend passed to it in argument.Some important points to note while using friend functions in C++:* The keyword friend is placed only in the function declaration of the friendfunction and not in the function definition..* It is possible to declare a function as friend in any number of classes..* When a class is declared as a friend, the friend class has access to theprivate data of the class that made this a friend..* A friend function, even though it is not a member function, would have therights to access the private members of the class..* It is possible to declare the friend function as either private or public..* The function can be invoked without the use of an object. The friend functionhas its argument as objects, seen in example below.properties of friend function:1. if a function to be made friend of a class than it should be declared within bodyof the class priciding with keyword friend.2.freind function never breaks the security.3.it should not be defined in name of class nor scope resolution operator is used in it'sdefination even the keyword freind is also not used while defining friend function.4.when friend function is called nither name of object nor dot operator is used. howeverit may accept the object as argument who's value it want's to access.5.it doen't matter in which section of the class we have declared a freind function.Example to understand the friend function:#includeclass exforsys{private:int a,b;public:void test(){a=100;b=200;}friend int compute(exforsys e1)//Friend Function Declaration with keyword friend and with the object of class exforsys to which it is friend passedto it};int compute(exforsys e1){//Friend Function Definition which has access to private datareturn int(e1.a+e2.b)-5;}main(){exforsys e;e.test();cout


What is message passing in c plus plus?

-define class with necessary data member & member function. -create object of that class. -communication.


What is friend datatype in object-oriented programming?

A friend is any class, class method or function that is declared to be a friend of a class. Friends have private access to the classes that declare them friends.


A friend Jessica's cat which one is the direct object?

A noun (or a noun phrase) will function as the subject of a sentence or a clause, and as the object of a verb or a preposition.The word 'friend' is a noun.The term 'Jessica's cat' is a noun phrase.Examples:We brought Jessica's cat a friend to play with. (the noun 'friend' is the direct object of the verb 'brought' [brought what? a friend]; the noun phrase 'Jessica's cat is the indirect object of the verb brought)She called Jessica's cat her friend. (the noun phrase 'Jessica's cat' is the direct object of the verb 'called' [called who? Jessica's cat]; the noun 'friend' is the object complement [renames the direct object])


How do you if an object is receiving more heat then it is passing on receiving less heat than it is passing on or receiving and passing on the same amount?

You can determine if an object is receiving more heat than it is passing on by monitoring its temperature increase. If the object's temperature is rising, it is receiving more heat than it is passing on. If the object's temperature is dropping, it is passing on more heat than it is receiving. If the object's temperature remains constant, it is receiving and passing on heat at the same rate.


What are the two parts of compilation?

1) source program to object program 2)object program to object program output


What is the correct pronoun case for my best friend and I or my best friend and me?

The pronoun case for "my best friend and I" is subjective; a noun phrase that can function as the subject of a sentence or a clause.The pronoun case for "my best friend and me" is objective, a noun phrase that can function as the object of a verb or a preposition.Examples:My best friend and I are taking a cruise together. (subject of the sentence)The cruise is a prize that my best friend and Iwon. (subject of the relative clause)The radio station called my best friend and me to give us the good news. (direct object of the verb 'called')A cruise will be a great time for my best friend and me. (object of the preposition 'for')


Call by ref are passing object?

yeah.... in call by reference, the real object is passed and whatever are the changes done to that object, they are reflected even on returning back from the function. so actual values are passed rather than the copy of them as in case of call by value.


What is an object function?

A function object is a computer programming construct allowing an object to be invoked or called as if it were an ordinary function, usually with the same syntax ...


Why friend are used in object oriented programing?

A friend function is a function that cannot be declared a member of a class but which requires private access to that class. For example, a function that operates upon two different classes cannot be a member of both classes, but if the function requires private access to both classes then it has to be a friend to at least one of them.To fully appreciate friend functions, consider that a non-static member function has the following three properties:Has private access to the class.Is scoped to the class.Must be invoked against an object of the class (has a 'this' pointer).Static member functions have the first two properties only while friend functions have the first property only. All other non-member functions have none of these properties.