explicit是什么意思

2025-02-28 04:34:23
推荐回答(3个)
回答1:

显式地,C++提供了关键字explicit,声明为explicit的构造函数不能用于隐式转换。
等级测试1
{
公共:
test1(int n){ num = n;}//通用构造函数
私人:
int num
};
等级测试2
{
公共:
explicit test 2(int n){ num = n;}//显式构造函数
私人:
int num
};
int main()
{
Test1 t1 = 12//隐式调用其构造函数,成功
Test2 t2 = 12//编译错误,无法隐式调用其构造函数。
test2 T3(12);//显式调用成功
返回0;
}
都是复制粘贴,因为问题比较简单。怎么能省事呢?一站式出国留学攻略 http://www.offercoming.com

回答2:

explicit
[英][ɪkˈsplɪsɪt][美][ɪkˈsplɪsɪt]
adj.
明确的,清楚的; 直言的; 详述的; 不隐瞒的;
形近词:sexplicitimplicitsexplicit

1
We are quite explicit about political affairs.
我们对政治问题态度十分明朗。

2
There just isn 't much explicit incentive for the enterprise stalwarts to move that aggressively to the web.
现在还缺乏明确的激励,促使传统软件商强势进军云计算领域。

回答3:

explicit
[英][ɪkˈsplɪsɪt][美][ɪkˈsplɪsɪt]
adj.
明确的,清楚的; 直言的; 详述的; 不隐瞒的;

双语例句
1
We are quite explicit about political affairs.
我们对政治问题态度十分明朗。