Please explain what strcpy is doing in this program. Also what is friend and the ostream& represent?? And I am not familiar with what the operator function is doing?
[tt]
#include <iostream.h>
#include <string.h>
class Building
{
public:
Building(char *room, int rmNum, char *cubicle) //CONSTRUCTOR
{
strcpy(Building::room,room);
Building::rmNum = rmNum;
strcpy(Building::cubicle,cubicle);
};
friend ostream& operator << (ostream& myoutput, Building s1);
private:
char room[200];
int rmNum;
char cubicle[200];
};
ostream& operator << (ostream& myoutput, Building s1)
{
cout << "Room nam = " << s1.room << "\nRoom num = " << s1.rmNum
<< "\nCub = " << s1.cubicle << endl;
return myoutput;
}
void main()
{
Building object1("Room1", 10, "234-4T"
;
cout << "First object info\n"
<< "-----------------\n" << object1 << endl;[/tt]
[tt]
#include <iostream.h>
#include <string.h>
class Building
{
public:
Building(char *room, int rmNum, char *cubicle) //CONSTRUCTOR
{
strcpy(Building::room,room);
Building::rmNum = rmNum;
strcpy(Building::cubicle,cubicle);
};
friend ostream& operator << (ostream& myoutput, Building s1);
private:
char room[200];
int rmNum;
char cubicle[200];
};
ostream& operator << (ostream& myoutput, Building s1)
{
cout << "Room nam = " << s1.room << "\nRoom num = " << s1.rmNum
<< "\nCub = " << s1.cubicle << endl;
return myoutput;
}
void main()
{
Building object1("Room1", 10, "234-4T"
cout << "First object info\n"
<< "-----------------\n" << object1 << endl;[/tt]