[code]#include <turboc.h>
class Time;
class Date
{
private:
int year, month, day;
public:
Date(int y, int m, int d)
{
year = y;
month = m;
day = d;
}
void outToday(Time &t);
};
class Time
{
friend void Date::outToday(Time &t);
private:
int hour, min, sec;
public:
Time(int h, int m, int s)
{
hour = h;
min = m;
sec = s;
}
};
void Date::outToday(Time &t)
{
printf("Today (%d.%d.%d) Time %d:%d:%d\n",
year, month, day, t.hour, t.min, t.sec);
}
void main()
{
Date D(2004,12,11);
Time T(12, 34, 22);
D.outToday(T);
}[/code]
class Time;
class Date
{
private:
int year, month, day;
public:
Date(int y, int m, int d)
{
year = y;
month = m;
day = d;
}
void outToday(Time &t);
};
class Time
{
friend void Date::outToday(Time &t);
private:
int hour, min, sec;
public:
Time(int h, int m, int s)
{
hour = h;
min = m;
sec = s;
}
};
void Date::outToday(Time &t)
{
printf("Today (%d.%d.%d) Time %d:%d:%d\n",
year, month, day, t.hour, t.min, t.sec);
}
void main()
{
Date D(2004,12,11);
Time T(12, 34, 22);
D.outToday(T);
}[/code]
'Native > C++' 카테고리의 다른 글
const member (0) | 2013.10.02 |
---|---|
static member (0) | 2013.10.02 |
friend class (0) | 2013.10.02 |
friend func (0) | 2013.10.02 |
kbhit() (0) | 2013.10.02 |