Just a C++ tutorial
-
-
one of the many "DON'TS" in C++ i hope this tutorial is just a "do not"
-
one of the many "DON'TS" in C++ i hope this tutorial is just a "do not"
I'm afraid not - it seems to be a genuine "tutorial" site... Perhaps he is just doing job creation: "If I teach them to code like this, I can get the job of fixing it"?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
I'm afraid not - it seems to be a genuine "tutorial" site... Perhaps he is just doing job creation: "If I teach them to code like this, I can get the job of fixing it"?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
Elephanting scary. Allocate a variable on the local stack frame, then return a pointer to it. X| Definitely a make-work for somebody. Cheers, Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
Elephanting scary. Allocate a variable on the local stack frame, then return a pointer to it. X| Definitely a make-work for somebody. Cheers, Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
I know what you mean. Way too easy to do by mistake, and a real PITA to find and fix in a big project. Definitely not something you should be teaching people to do. :omg:
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
I know what you mean. Way too easy to do by mistake, and a real PITA to find and fix in a big project. Definitely not something you should be teaching people to do. :omg:
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
nevertheless the pointer is immediately dereferenced, so in this example it is perfectly OK :laugh:
-
nevertheless the pointer is immediately dereferenced, so in this example it is perfectly OK :laugh:
Of course! :laugh: Don't you just love code that works more by luck than by judgement? ;)
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
You what! Hmm, I spent many happy hours tracking down a strange bug in a database library I was using that was a subtle variant of this: The library passed data objects by value, but treated them as passed by reference: this worked when compiled with Borland C++, because the optimiser effectively took away the creation of the temporary stack objects that are required by the spec and passed a reference. gcc did it properly though, and allocated the temporary objects and then threw them away - result, the system worked perfectly on Windows (compiled with Borland) and failed in mysterious ways on Linux. To their credit, once I told the authors, they fixed it very quickly... 8) Perhaps this chap used to work for them...
-
Of course! :laugh: Don't you just love code that works more by luck than by judgement? ;)
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
A sudden sense of not being a hack has temporarily settled down over me.
-
How could this possibly work? If we declare a pointer to a variable declared in the stack, the variable will be valid only as long as the current stack frame is active. When the control returns to the caller, wouldn't the variable be lost in stack? I mean, if we call another function in sequence, wouldn't it be overwritten?
Interested in Machine Learning in .NET? Check the Accord.NET Framework. See also Handwriting Recognition Revisited: Kernel Support Vector Machines
-
How could this possibly work? If we declare a pointer to a variable declared in the stack, the variable will be valid only as long as the current stack frame is active. When the control returns to the caller, wouldn't the variable be lost in stack? I mean, if we call another function in sequence, wouldn't it be overwritten?
Interested in Machine Learning in .NET? Check the Accord.NET Framework. See also Handwriting Recognition Revisited: Kernel Support Vector Machines
Why do you think it's a code horror? =P
Fratelli
-
Why do you think it's a code horror? =P
Fratelli
Immediately after posting I realized where I was X|
Interested in Machine Learning in .NET? Check the Accord.NET Framework. See also Handwriting Recognition Revisited: Kernel Support Vector Machines
-
This tutorial should be called: "How to get your first access violation runtime error in C++".