On Sun, Feb 14, 2010 at 10:46 AM, Carlos Konstanski < [email protected]> wrote:
> I have a C++ function I'm writing; see below. I'm new to C++, and the > implementation details tend to bite me where the sun don't shine > whenever they can. > > The function works as intended. But later attempts to use the value > that I passed in as rawInput cause an error in Visual C++. GNU C++ > does not give me any error. Nevertheless, I think that there must be a > problem here. I suspect that the pointer charSequence must need to be > freed. But I cannot find any way to do this that compiles. > > Is this my problem? If so, how do I free charSequence? > As the other responders pointed out, you don't. The problem appears to be, and I'm guessing here, that the deletion of the automatic variable charSequence is somehow affecting the original rawInput instance, like maybe deleting the contents there. Since your function declaration uses the 'call by value' method (pass in a copy) rather than the 'call by reference' method (pass in a pointer), things are a little more obscured. What is the error message from Visual C++? What is the value of rawInput in the g++ version after the call returns? - tony _______________________________________________ PLUG mailing list [email protected] http://lists.pdxlinux.org/mailman/listinfo/plug
