首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
在下向程序和横线处填上适当的内容,使程序执行后的输出结果为1/2005。 #include <iostream> using namespace std; class Date { public: Date(int m=
在下向程序和横线处填上适当的内容,使程序执行后的输出结果为1/2005。 #include <iostream> using namespace std; class Date { public: Date(int m=
admin
2009-01-15
94
问题
在下向程序和横线处填上适当的内容,使程序执行后的输出结果为1/2005。
#include <iostream>
using namespace std;
class Date
{
public:
Date(int m=1,int y=0):month(m),year(y){}
void Print() {cout<<month<<"/"<<year<<end 1; }
【 】 operator+(eonst Date& d1, const Date& d2);
private:
int month,year;
};
【 】 operator+(const Date& d1, const Date& d2)
{
int year,month;
year=d1.year+d2.year;
month=d1. month+d2.month;
year+=(month-1 )/12;
month=(month-1 )% 12+1;
return Date(month,year);
}
void main()
Date d1 (3,2004),d2,d3(10);
d2=d3+d1;
d2,Print();
}
选项
答案
friend Date Date
解析
重载及友元的相关内容。
转载请注明原文地址:https://kaotiyun.com/show/Zkkp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
若要使用C数学库中的sin函数,需要在源程序的头部加上#include关于引用数学库,以下叙述正确的是()。
设有如下定义和语句:[1]char*s;s="string";[2]chars[7];s="string";[3]chars[]="string";[4]chars[]={’s’,’t’,’r’,’i’,’n’,’g’};其中定义项可以作为
下面的for语句的循环次数为()。for(x=1,y=0;(y!=19)&&(x<6);x++);
表达式:(int)((double)9/2)—(9)%2的值是()。
在C语言源文件中定义的全局变量的作用域为()。
某二叉树中度为2的结点有10个,则该二叉树中有()个叶子结点。
对长度为n的线性表作快速排序,在最坏情况下,比较次数为
设有如下定义struct{intn;charc;}a[2],*p=a;则以下错误引用结构体成员n的是()。
以下选项中不属于C语言程序运算符的是
以下关于C语言函数参数传递方式的叙述正确的是()。
随机试题
心力储备包括
男,65岁。右侧阴囊逐渐增大5年,无疼痛,查体见右侧阴囊肿大,大小约15cm×10cm,呈囊性,未触及睾丸,透光试验阳性,首先应考虑的诊断是
国际上通常认为,一国65岁以上人口占总人口()以上者为老龄化国家。
(2005年)下列结论中错误的是()。
下列不属于货物采购合同管理内容的是()。
请用不超过200字的篇幅,概括出给定材料所反映的主要问题。要求:全面,有条理,有层次。就给定资料所反映的主要问题,用1200字左右的篇幅,自拟标题进行论述。要求中心明确,内容充实,论述深刻,有说服力。
根据以下资料,回答下列问题。2008年国内增值税、消费税的总收入为16066.03亿元,出口货物退增值税、消费税5865.93亿元。那么,2008年中央财政总收入约为()亿元。
设A=,则(A+3E)-1(A2-9E)=______.
KeepingitintheFamilyForexpatparents,passingontheirnativelanguagescanbeastruggle."Youunderstandgrandmotherwhe
A、Tofindabetterrecordinthestore.B、Nottomissanychancetogettherecord.C、Tobuyallthefavoriterecords.D、Notto
最新回复
(
0
)