为什么会出现这种情况
#include<iostream>
using namespace std;
class Point;
class Complex
{
int real;
int img;
public:
friend void Point::print(const Complex &m);
Complex(int a,int b)
{
real=a;
img=b;
}
void show()
{
cout<<real<<" "<<img;
}
};
class Point
{
int x;
int y;
public:
Point(int j,int k)
{
x=j;
y=k;
}
void print(const Complex &m);
};
void Point::print(const Complex &m)
{
cout<<x<<" "<<y<<endl;
m.show();
}
int main()
{
Complex c1(4,5);
Point c2(2,4);
c2.print(c1);
}
#include<iostream>
using namespace std;
class Complex;
class Point
{
int x;
int y;
public:
Point(int j,int k)
{
x=j;
y=k;
}
void print(const Complex &m);
};
class Complex
{
int real;
int img;
public:
friend void Point::print(const Complex &m);
Complex(int a,int b)
{
real=a;
img=b;
}
void show() const
{
cout<<real<<" "<<img;
}
};
void Point::print(const Complex &m)
{
cout<<x<<" "<<y<<endl;
m.show();
}
int main()
{
Complex c1(4,5);
Point c2(2,4);
c2.print(c1);
}