+ -
当前位置:首页 → 问答吧 → ubuntu中安装ANDROID环境和MYECPLISE的环境。最好可以两个都独立?

ubuntu中安装ANDROID环境和MYECPLISE的环境。最好可以两个都独立?

时间:2011-11-06

来源:互联网

代码:
#include<iostream>
#include<string>
using namespace std;
class Date;
class Employee
{
public:
   Employee(string str,int en,int y,int m,int d):birthday(y,m,d)
   {
      name=str;
      employeenumber=en;
   }
   int IsBirthday(const Date &t)
   {
      if(birthday.year==t.year && birthday.month==t.month && birthday.day==t.day)
         return 1;
      else return 0;
   }
private:
   Date birthday;
   string name;
   int employeenumber;
};
class Date
{
public:
   Date(int y=0,int m=0,int d=0)
   {
      year=y;
      month=m;
      day=d;
   }
   friend void Employee::show();
   friend int Employee::IsBirthday(const Date &t);
private:
   int year;
   int month;
   int day;
};
int main()
{
   Employee Tom("Tom",10,1980,11,20);
   Date today(1980,11,20);
   if(Tom.IsBirthday(today))
      cout<<"Today is Tom's Birthday."<<endl;
   else cout<<"Today is not Tom's Birthday."<<endl;
   return 0;
}
想让Employee去访问Date类,如果让Employee类的定义放在Date类前面,提前声明Date类,但是Employee里面用了组合,也就是定义了一个Date的对象,这不能编译通过;如果Date类定义放在Employee,也不能通过。求各位指教了~

作者: fireandice   发布时间: 2011-11-06