求C++编程帮忙(using friend method)
#include<iostream.h>#include<string.h>
class Point;
class Information
{
friend class Point;
private:
char name[30],id[10];
public:
void setdata(char *,char *);
};
void Information::setdata(char * a,char * b)
{
strcpy(name,a);
strcpy(id,b);
}
class Point
{
int cumulated_point,current_point,total_point;
public:
void set_point(int,int);
void calculate_point();
void display(Information);
};
void Point::set_point(int point1,int point2)
{
cumulated_point=point1;
cumulated_point=point2;
}
void Point::calculate_point()
{
total_point=cumulated_point + current_point;
}
void Point::display(Information a)
{
cout<<"Member's Name:"<<a.name<<"\n";
cout<<"ID :"<<a.id<<"\n";
cout<<"Total Point :"<<total_point<<"\n";
if (total_point> 1000)
cout<<"Qualified to be VIP Member.";
else
cout<<"Not qualified to be VIP Member.";
cout<<'\n';
}
void main()
{
char name[30],id[10];
int cumulated_point,current_point;
Point a;
Information b;
cout<<"Name:";
cin.getline(name,30);
cout<<"ID :";
cin.getline(id,10);
cout<<"Cumulated Point :";
cin>>cumulated_point;
cout<<"Current Point :";
cin>>current_point;
cout<<'\n';
b.setdata(name,id);
a.set_point(cumulated_point,current_point);
a.calculate_point();
a.display(b);
}