标题:&的意思
取消只看楼主
换空依晨
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2013-9-13
结帖率:30.77%
 问题点数:0 回复次数:1 
&的意思
程序代码:
#include"stdio.h"
#include"iostream.h"
#include "string.h"
typedef char string80[80];
class Date
{
public:
    Date() {}
    Date(int y,int m,int d)
    {
    SetDate(y,m,d);
    }
     void SetDate(int y,int m,int d)
     {     Year=y;
        Month=m;
        Day=d;
     }
    string80& GetStringDate(string80 &Date)
    {
    sprintf(Date,"%d/%d/%d",Year,Month,Day);
    return Date;

    }
protected:
    int Year,Month,Day;
};
class Time
{
public:
    Time() {}
    Time(int h,int m,int s)
    {
    SetTime(h,m,s);
    }
     void SetTime(int h,int m,int s)
     {     Hours=h;
        Minutes=m;
        Seconds=s;
     }
    string80& GetStringTime(string80 &Time)
    {
    sprintf(Time,"%d:%d:%d",Hours,Minutes,Seconds);
    return Time;

    }
protected:
    int Hours,Minutes,Seconds;
};
class TimeDate:public Date,public Time
{
public:
    TimeDate():Date() {}
    TimeDate(int y,int mo,int d,int h,int mi,int s):Date(y,mo,d),Time(h,mi,s) {}
    string80&  GetStringDT(string80 &DTstr)
    {
    sprintf(DTstr,"%d/%d/%d;%d:%d:%d",Year,Month,Day,Hours,Minutes,Seconds);
    return DTstr;

    }
};
void main()
{
TimeDate date1,date2(2008,6,5,10,15,05);
string80 DemoStr;
date1.SetDate(2008,9,10);
date1.SetTime(19,07,30);
cout<<"the date1 date and time is:"<<date1.GetStringDT(DemoStr)<<endl;
cout<<"the date1 date is:"<<date1.GetStringDate(DemoStr)<<endl;
cout<<"the date1 time is:"<<date1.GetStringTime(DemoStr)<<endl;
cout<<"the date2 date and time is:"<<date2.GetStringDT(DemoStr)<<endl;
}

string80&  GetStringDT(string80 &DTstr) 这里面第一个&和第二个&分别有什么意思啊 不理解
搜索更多相关主题的帖子: public 
2014-02-26 10:38
换空依晨
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2013-9-13
得分:0 
回复 2楼 dendi
怎么引用的 能详细点吗
2014-02-26 12:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-427684-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.092306 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved