Java和简单变量C ++ [英] Simple Variables in Java & C++
问题描述
我在一些matrials中看到这个句子:
在Java中,简单的数据类型如int和char的操作与C中一样。
我想知道,他们实际上是不同的Java& C ++?
在C ++中,像Java中的基元的简单变量也被分配一个内存地址,因此C ++中的这些基本类型也可以有一个指针。然而,Java中的基元没有分配一个内存地址,如Objects。
我是否正确?
谢谢!
几乎。
在java原语中也分配了内存,但是这发生在内部, p>
这是为了提供内存管理的安全性。
I saw this sentence in some matrials:
"In Java, simple data types such as int and char operate just as in C."
I am wondering that actually they are different in Java & C++?
In C++, simple variables like the primitives in Java are assigned a memory address as well, so these primitive types in C++ can have a pointer as well. However primitives in Java are not assigned a memory address like Objects are.
Am I correct?
Thanks!
Almost.
In java primitives are assigned memory as well, but this happens internally and you cannot get the reference.
Thre reason was to provide security on memory management.
这篇关于Java和简单变量C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!