[Solved] Why need new operator in java but not in c++

C++ and Java have similar syntax but not always means the same. In Java all objects are references, so when you’re doing Classname obj; you’re creating a empty reference to an object, so you need to assign something to it. Classname obj; //here obj is pointing to nothing. obj = new Classname(); //here obj is … Read more

[Solved] New and delete command of c++ in obj-c

You would utilize the alloc and init (or more specialized initializer) provided by NSObject. For example, something like the following should work: int fromuser, a; NSMutableArray objectArray = [[NSMutableArray alloc] initWithCapacity:fromuser]; for (a = 0; a < fromuser; a++) { MyObject *obj = [[MyObject alloc] init]; [objectArray addObject:obj]; [obj release]; //If not using ARC } … Read more