当它为空时,默认构造函数做什么? [英] what does default constructor do when it's empty?
本文介绍了当它为空时,默认构造函数做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
我想知道是否有人可以解释内存分配后的默认ctor是如何做的,我不知道你问的问题,但我会尽力回答C ++和Java
在C ++,它:
- 保留内置类型(
int
,float $ c $
在Java中,我认为所有的类成员都被初始化为默认值(0或NULL)。
I wonder if anyone could explain what the default ctor does after memory allocated, how it initializes the allocated memory?
解决方案
I don't know which languange you asked the question for, but I will try to answer anyway for C++ and Java
In C++, it :
- leaves the built-in types (
int
,float
, pointers, etc.) to an uninitialized value - calls the default constructor on class members
In Java, I think all class members are initialized to their default value (0 or NULL).
这篇关于当它为空时,默认构造函数做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文