c++ - int a = int(); 这个int()是什么用法呢?
PHP中文网
PHP中文网 2017-04-17 13:51:31
0
1
526

下面这段代码

int a = int();
cout<<a<<endl;

输出是0;

我想知道这个int()是什么用法。或者您可以告诉我用什么名词可以搜索到这个内容,我想具体得了解一下。

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
伊谢尔伦

Keywords: constructor

For a type, the type name itself is the constructor of the type
For example, there is a class

class A {
    ...
};

Then A() is the constructor of type A. Using A() you can get a variable of type A.
int is a built-in type, so int() calls the constructor of the int type and returns an int variable.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template