Click here to Skip to main content
15,881,559 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Greg Utas9-Mar-20 1:34
professionalGreg Utas9-Mar-20 1:34 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Member 91670578-Mar-20 22:18
Member 91670578-Mar-20 22:18 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
John R. Shaw26-Mar-20 19:52
John R. Shaw26-Mar-20 19:52 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Nelek26-Mar-20 23:31
protectorNelek26-Mar-20 23:31 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
kalberts29-Mar-20 12:26
kalberts29-Mar-20 12:26 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Stefan_Lang8-Mar-20 23:51
Stefan_Lang8-Mar-20 23:51 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Gary R. Wheeler9-Mar-20 12:36
Gary R. Wheeler9-Mar-20 12:36 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Stefan_Lang9-Mar-20 21:32
Stefan_Lang9-Mar-20 21:32 
Unfortunately, new creates an object on the heap, and it does return a pointer. That corresponds to the left hand side. Also, it's not obvious to the compiler to understand what you intended. If you had constructed a class instance instead, it would be quite reasonable. While creating an integral type on the heap is quite unusual, it might still make sense if that code is part of a template implementation:
C++
template <class T>
T* copy(T& const source) {
    return  new T(source);
}

This code works for any kind of class, but also for integral types. So why should the compiler complain?

However, the crux of the problem is that C/C++ treat {addreess to first element of array} the same as {address of object}. It doesn't differentiate the two, and that is why your assignment doesn't even raise a warning.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

GeneralRe: Lets' change things up; how about the inept and stupid Pin
Gary R. Wheeler10-Mar-20 6:59
Gary R. Wheeler10-Mar-20 6:59 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Nelek26-Mar-20 23:29
protectorNelek26-Mar-20 23:29 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Richard MacCutchan26-Mar-20 23:43
mveRichard MacCutchan26-Mar-20 23:43 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Marc Clifton27-Mar-20 8:16
mvaMarc Clifton27-Mar-20 8:16 
GeneralRe: Lets' change things up; how about the inept and stupid Pin
Greg Utas27-Mar-20 11:01
professionalGreg Utas27-Mar-20 11:01 
GeneralWonderful: For those of you that want to teach yourself more advanced CS concepts Pin
honey the codewitch26-Feb-20 9:44
mvahoney the codewitch26-Feb-20 9:44 
GeneralRe: Wonderful: For those of you that want to teach yourself more advanced CS concepts Pin
Amarnath S26-Feb-20 13:32
professionalAmarnath S26-Feb-20 13:32 
GeneralRe: Wonderful: For those of you that want to teach yourself more advanced CS concepts Pin
vaghelabhavesh27-Feb-20 8:40
vaghelabhavesh27-Feb-20 8:40 
GeneralRe: Wonderful: For those of you that want to teach yourself more advanced CS concepts Pin
John R. Shaw26-Mar-20 20:02
John R. Shaw26-Mar-20 20:02 
GeneralRe: Wonderful: For those of you that want to teach yourself more advanced CS concepts Pin
honey the codewitch26-Mar-20 20:16
mvahoney the codewitch26-Mar-20 20:16 
GeneralThis Definitely Falls into the Wonderful Camp Pin
David A. Gray9-Feb-20 11:14
David A. Gray9-Feb-20 11:14 
GeneralRe: This Definitely Falls into the Wonderful Camp Pin
Randor 10-Feb-20 12:33
professional Randor 10-Feb-20 12:33 
GeneralRe: This Definitely Falls into the Wonderful Camp Pin
David A. Gray11-Feb-20 10:33
David A. Gray11-Feb-20 10:33 
GeneralRe: This Definitely Falls into the Wonderful Camp Pin
Randor 11-Feb-20 12:40
professional Randor 11-Feb-20 12:40 
GeneralVisual Studio 2019 and the Weird, Wonderful Nonbreaking Space Pin
David A. Gray8-Feb-20 11:33
David A. Gray8-Feb-20 11:33 
GeneralRe: Visual Studio 2019 and the Weird, Wonderful Nonbreaking Space Pin
Super Lloyd29-Mar-20 13:50
Super Lloyd29-Mar-20 13:50 
GeneralRe: Visual Studio 2019 and the Weird, Wonderful Nonbreaking Space Pin
Greg Utas29-Mar-20 14:31
professionalGreg Utas29-Mar-20 14:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.