RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

C++ Arrays

Sep102

Page
You've never used the syntax because placement-new isn't really used all too often, at least as far as I've seen. It can be really useful when you actually need it, but in general standard new provides most of the functionality you would need (Or, at least, that's my take on the matter).

And, technically my (milt's) example uses the same method for memory allocation, I just construct the instances of the Month in a different way, closer to the way C# does it then copied them over to where I was going to persist them.

Really, you wouldn't do it your way either, in general, maybe (Probably not still though, if I was expecting to construct multiple objects at once as an array on the heap, I'd provide some Initialize() function or something of the sort rather than calling the constructor on each of them after allocating them), but at least in this instance it's not really a good idea to re-create the months every time, at least as it is. Like I said earlier, it would be a better idea to create them once then make a copy of them each time they're needed for a new instance (if it's mutable, of course), of which my example is very well suited to perform.
 
Top