| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 389 人关注过本帖
标题:棘手的问题,此程序如何改为面向对象形式,求解!
只看楼主 加入收藏
单调黑白
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2007-10-4
收藏
 问题点数:0 回复次数:2 
棘手的问题,此程序如何改为面向对象形式,求解!
棘手的问题,此程序如何改为面向对象形式,求解!
#include<time.h>
#include<iostream>
using namespace std;

int main(void)
{
struct tm *local;
time_t t;

t=time(NULL);
local=localtime(&t);
cout<<"local time and date:"<<asctime(local)<<endl;

return 0;
}
搜索更多相关主题的帖子: include return local 如何 
2007-11-05 17:05
单调黑白
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2007-10-4
收藏
得分:0 
回复:(单调黑白)棘手的问题,此程序如何改为面向对象...
问题补冲:
此程序输出的本地日期及时间如何改变为"yyyy-mm-dd HH:MM:SS"形式! 谢谢!

雕刻单调的人生
2007-11-05 17:10
高温煎饺
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2007-11-2
收藏
得分:0 

随便改的,比较简陋~呵呵
#include<time.h>
#include<iostream>
using namespace std;
class Time
{
private:
struct tm *local;
time_t t;

public:

Time()
{
t=time(NULL);
local=localtime(&t);
}

void display()
{
char* buff;
char buff1[20];
int j=0;

buff=asctime(local);

for(int i=20;i<24;i++,j++)
buff1[j]=buff[i];

buff1[j]=' ';

j ++;

for(i=4;i<20;i++,j++)
buff1[j]=buff[i];

cout<<"local time and date:";
for(i=0;i<20;i++)
cout<<buff1[i];

cout<<endl;
}



};
int main(void)
{

Time time;
time.display();


return 0;
}

follow your heart
2007-11-06 13:00
快速回复:棘手的问题,此程序如何改为面向对象形式,求解!
数据加载中...
 
   



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

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