单项选择题
下列关于构造函数的描述中,错误的是
A.构造函数可以设置默认参数
B.构造函数在定义类对象时自动执行
C.构造函数可以是内联函数
D.构造函数不可以重载
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
有如下程序: #include <iostream> using namespace std; int s=0; class sample static int n; public: sample(int i) n=i; static void add() s+=n; ; iht sample::s=0; iht main() sample a(2),b(5); sample::add(); cout<<s<<end1; return 0; 程序运行后的输出结果是
A.2
B.5
C.7
D.3
点击查看答案&解析
填空题
下面程序的运行结果是 【9】 。 #include <iostream> using namespace std; class count static int n; public: count() n++; static int test() for(int i=0;i<4;i++) n++; return n; ; int count::n = O; int main() cout<<count:: test()<< ; count c1, c2; cout<<count:: test()<<endl; return 0;
点击查看答案&解析
相关试题
【13】 允许用户为类定义一种模式,使得...
有以下程序: #include <iostream> u...
下面是复数类complex的定义,其中作为友元...
数据库系统中实现各种数据管理功能的核心软...
在下面横线上填上适当的语句,完成程序。 ...