吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2808|回复: 5
收起左侧

[C&C++ 转载] c++的,谁帮我看下哪里出错了

[复制链接]
sinker 发表于 2013-10-14 15:20
#include<iostream>
using namespace std;
class Date;                       //对Date类的提前引用声明
class Time                        //定义Time 类
{ public:
     Time(int,int,int);
     friend void display(const Date &,const Time &); //将普通函数display声明为朋友
   private:
     int hour;
     int minute;
     int sec;
};



Time::Time(int h,int m,int s)      //类Time的构造函数
{  hour=h;
   minute=m;
   sec=s;
}

class Date
{public:
  Date(int,int,int);
  friend void display(const Date &,const Time &);      //将普通函数display声明为朋友
private:
        int month;
        int day;
        int year;
};


Date::Date(int m,int d,int y)                   //类Date的构造函数
{  month=m;
   day=d;
   year=y;
}

void display(const Date &d,const Time &t)        //是Time和Date两个类的朋友
{
        cout<<d.month<<"/"<<d.day<<"/"<<d.year<<endl;    //引用Date类对象t1中的数据成员
    cout<<t.hour<<":"<<t.minute<<":"<<t.sec<<endl;   //引用Time类对象t1中的数据成员
}

int main()
{  
   Time tl(10,13,56);   //定义Time类对象tl
   Date dl(12,25,2004); //定义Date类对象dl
   display(dl,t1);     // 调用display函数,用对象名做实参
   return 0;
}


程序是要输出年月日,和时分秒 老是编译不了

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

海水很咸 发表于 2013-10-14 16:19
没什么问题,运行结果正常 只有一个地方
display(dl,tl);    tl (字母L小写)  不是t1(数字1234)
duliangang 发表于 2013-10-14 16:21
display(dl,t1);     // 调用display函数,用对象名做实参
把t1改成tl
头像被屏蔽
yuan71058 发表于 2013-10-14 17:18
RinCherish 发表于 2013-10-15 11:56
孩子 ~ 加油~
 楼主| sinker 发表于 2013-10-15 22:54
海水很咸 发表于 2013-10-14 16:19
没什么问题,运行结果正常 只有一个地方
display(dl,tl);    tl (字母L小写)  不是t1(数字1234)

谢谢啦!我一直看不出来
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-3-29 03:53

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表