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
C Program for FUNCTION OF COUNT THE CHARACTERS IN EACH WORD void count(char c[]); void main() {           char a[50];           int i=0;           clrscr();

I need vsti program Project Description: Knowledge of vsti programs, and music is a plus, ex: nexus I will input the sounds I just need the interface built Skills required

Question : (a) Define the following Object-Oriented terms: (i) Encapsulation (ii) Inheritance (iii) Abstraction (iv) Polymorphism. (b) What are objects in Lingo progra

Define the Float Data Type of c Language? The float is used to define floating point numbers. The Floating point numbers are stored in 32 bits with 6 digits of precision. Eg

Exceptions. Your SVector class should throw four exceptions: 3.1. If the constructor size is invalid, then it will just allow the implicit STL bad_alloc exception to pass up to mai

Should I call a destructor explicitly on a local variable?

A student apears in exam of math, physics, and chemistry. Write a program to find the total marks aa student has aqueired find the average.

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec