[Solved] Problems with char * and delete [duplicate]

You can delete only what was allocated using the corresponding operator new. String literals have static storage duration. They are not dynamically allocated. According to the C++ Standard 8 Ordinary string literals and UTF-8 string literals are also referred to as narrow string literals. A narrow string literal has type “array of n const char”, … 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