ForNext
Only Do What Only You Can Do
010. allocate primitive type on heap
Hyperpolyglot C++ Style Languages: C++, Objective C, Java, C# より (2012.05.08)
VBScript
JScript
Perl
PHP
Python
Ruby
PowerShell
Scala
F#
C
C++
int *ip = new int;
C++Builder
VC++
C#
object i = 0;
Java
primitive types are always stack allocated. Use a wrapper class to store on the heap: Integer i = new Integer(0);
Objective-C
#include <stdlib.h> int *ip = malloc(sizeof(int));