请问为什么出错内详

bobshi 2003-03-27 04:11:25
#include <string.h>
#include <strstream.h>
//using namespace std;

class Date
{
public:
Date(int m=1,int d=1,int y=0);
Date(char* dstr);
void PrintDate();
private:
int month,day,year;
};

Date::Date(int m,int d, int y):month(m),day(d)
{
year=1900+y;
}

Date::Date(char* dstr)
{
char inputBuffer[16];
char ch;
strcpy(inputBuffer,dstr);
istrstream input(inputBuffer,sizeof(inputBuffer));//这一句出错用法是从流 //input中读入年月日用能 // 上能下ch过滤掉字符"/"
input >> month >> ch >> day >> ch >> year;
year+=1900;
}

void Date::PrintDate ()
{
static char* months[]={"","January","February","March",
"April","May","June","July","August","September","October","November","December"};
cout << Months[month] << "," << day << "," << year;
}
...全文
105 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
point_to 2003-03-27
  • 打赏
  • 举报
回复

#include "stdafx.h"
#include <strstream>
#include <strstrea.h>
//using namespace std;

class Date
{
public:
Date(int m=1,int d=1,int y=0);
Date(char* dstr);
void PrintDate();
private:
int month,day,year;
};

Date::Date(int m,int d, int y):month(m),day(d)
{
year=1900+y;
}

Date::Date(char* dstr)
{
char inputBuffer[16];
char ch='/';
strcpy(inputBuffer,dstr);
istrstream input(inputBuffer,sizeof(inputBuffer));
input >> month >>ch>> day >> ch >> year;
cout << month << "," << day << "," << year<<endl;
year+=1900;
}

void Date::PrintDate ()
{
static char* months[]={"","January","February","March",
"April","May","June","July","August","September","October","November","December"};
cout << month << "," << day << "," << year<<endl;
}



main()
{


Date dt("03/05/97");
dt.PrintDate();


}
pooryaya 2003-03-27
  • 打赏
  • 举报
回复
帮你UP一下!

70,021

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧