- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
/me draws a card.
hmm.... got any sevens?
Admin
Hey, wait for your turn!
Admin
Don't worry, it's just a @RaceProUK condition instigated by an @Accalia in the concurrent thread.
Admin
BEST COMMENT YET TODAY!
:rofl:
Admin
I worked with one woman who supposedly had a masters in CS. She knew syntax, sure, but I couldn't give her a single task without pseudo-coding the whole process for her. And, even then, she would completely mangle the logic half the time.
It's one thing if you want to bring in a junior dev to "help out" and learn, but all-too-often, companies tend to have the thought process "I know we need 2 senior developers on this project, but 1 senior developer and two junior developers is just as good". In the end, it just means that the senior developer ends up spending half his time "fixing" the junior dev's work (more, if you actually try and show them what they did wrong), and then gets yelled at when the dealine slips.
Admin
I wouldn't dream of it. One obvious reason is that you need something as a criterion to distinguish two objects, and it's the only thing left. In this case, the "sort by location in memory" isn't that you need them in that order so much as that you need them in an order, and location in memory is guaranteed to be unique for distinct objects.
Admin
In particular, this code is UB:
And so is this:
Why? Because C++98 (YMMV on C++11, although I doubt they'd have changed this) says that
new
andmalloc
don't necessarily use the same arena, and so they can only be used in matched pairs.EDIT: Sorry, forgot to mention that I chose
int
as the type to allocate to avoid all possibility of arguments about the other thing thatnew
does: calling the constructor of a constructable class.Admin
You could use
void* p = ::operator new( sizeof(int) );
and::operator delete( p )
, respectively, Those allocate from the same arena as the "normal"new
/delete
, but do not initialize memory in any way (i.e., no constructors etc). In a sense, those are the actual replacements formalloc()
/free()
in C++.