Home > Back-end >  C in friends metaclass how to access the array of another class member
C in friends metaclass how to access the array of another class member

Time:09-21

For each passing by the great god look at: the code is as follows:
In the Tri a class member function using cout

#include
#include
The class Tri.
The class Point
{
Private:
Int x, y;

Public:
Int q [3].
Point (int [c])
{
Q [0] [0]=c;
Q [1] [1]=c;
Q [2], [2]=c;
Cout<& lt;" Shuzu: "& lt; }
Xx=0 Point (int, int yy=0)
{
X=xx; Y=yy.
}
Friend class Tri;
};
The class Tri
{
Private:
Point pos1, pos2, pos3;
Public:
Tri (Point px1, Point px2, Point px3)
{pos1=px1; Pos2=px2; Pos3=px3; }
Double Area ();
};
Double Tri: : Area ()
{
Coutfor(int j=0; J<3; J++)
Coutreturn 0;
}
Void main ()
{
Int b [3]={1, 2, 3};
Point niu (b);
Pt2 Point pt1 (1, 1), (7, 1), the pt3 (4, 5);
Tri tria (pt1 pt2, pt3);
Tria. Area ();
}
  • Related