Friend function in c++, C/C++ Programming

Friend function in c++:

class miles;

class km


   float value;

   public :

  // void input();

    km convert(km  ,int a ) ;

   void output()


   cout << value;




                                km km :: convert(km a,int b)


                                a.value = b * 1.61;

                                return a;






                class miles


                   int value;



                   void input()


                   cout << "Enter the value\n";

                  cin >> value;


                   friend km & convert(km &,miles);



                km & convert(km & a,miles b)


                                a= b.value * 1.61;

                                return a;




   void main()


     km a;

     miles b;




     a= convert (a,b);




Posted Date: 10/18/2012 7:48:53 AM | Location : United States

Related Discussions:- Friend function in c++, Assignment Help, Ask Question on Friend function in c++, Get Answer, Expert's Help, Friend function in c++ Discussions

Write discussion on Friend function in c++
Your posts are moderated
Related Questions
Using a Friend Using a friend function is quite easy. The following example explains a friend function to access members of two classes. class Bclass;

Can you think of a condition where your program would crash without attaining the breakpoint that you set at the starting of main()? A: C++ let for dynamic initialization of glo

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

The default Constructor and Destructor If you fail to write a constructor and destructor function,  the compiler automatically supplies them for you. These functions have publi

Selecting Array Elements Implement the following C++ code in assembly language, using the block-structured .IF and .WHILE directives. Assume that all variables are 32-bit signed in

Shell sort - C Program: Write a program to define shell sort. void main() {                  //program for sorting by select sort int a[20],i,k,j,n;   clrscr();

I need help with a c# program. Do yall help with c sharp

In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color. Fill the other elements in the board, suc