单项选择题
有以下程序
#include <iostream>
using namespace std;
static int days []=31,28.31,30,31,30,31,31,30,31,30,31;
class date
private:
int month, day, year:
public:
date (int m, int d, int y
month = m;
day = d;
year = y;
date
void disp )
cout <<year<<" - "<<month<< "- "<<day<<end1;
date operator+(int day)
date dt = *this:
day += dt.day;
while day > days[ dt.month - 1 ] )
day -= tays[ dt.month - 1 ];
if ( ++dt.month == 13
dt.month = 1;
dt.yeare++;
dr. day = day;
return dt;
;
int main()
date d1( 6, 20, 2004 ), d2;
d2.= d1 + 20;
d2.disp ();
return 0;
执行后的输出结果是
A.2004-7-10
B.2004-6-20
C.2004-7-20
D.程序编译时出错
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
有以下类定义 class Point public: Pointint x = 0, int y=0) _x = x; _y = y; void Move int xoff, int yoff) _x +=xoff;_y+=yoff; void Print() const cout<<’(’<<_x<<’,’<<_y<<’)’ << end1; private: int_x,_y; ; 下列语句中会发生编译错误的是
A.Point pt;pt.Print();
B.const Point pt;pt.Print();
C.Point pt;pt.Move(1, 2);
D.const Point pt;pt.Move(1, 2)
点击查看答案&解析
单项选择题
有以下程序 #include <iostream> int i = 0; void fun( ) static int i = 1; std::cout<<i++<<’,’; std::cout<<i<<’,’; int main() fun(); fun(); return 0; 程序执行后的输出结果是
A.1,2,1,2,
B.1,2,2,3,
C.2,0,3,0,
D.1,0,2,0,
点击查看答案&解析
相关试题
有如下程序: #include <iostream.h>...
下列程序的输出结果是 #include <iostr...
有以下程序 #include <iostream> usi...