Showing posts with label Friend Function. Show all posts
Showing posts with label Friend Function. Show all posts

Friend Function Program in C++


/*A friend function allows you to generate more efficient
code. The following program illustrates this concept:*/


#include <iostream.h>
#include <conio.h>

const int IDLE = 0;
const int INUSE = 1;

class C2; // forward declaration

class C1 {

int status; // IDLE if off, INUSE if on screen

// ...

public:
void set_status(int state);
friend int idle(C1 a, C2 b);

};
Custom Search