Re: new/delete



c language said:

Hi,
I am using pointer in my program. I write them like:
*DIST=new int [M+1];

In C, that's a syntax error.

and when I want to make the memory free, I write:
delete DIST;

In comp.lang.c++ they will explain to you about the difference between new
and new [], and how to destroy objects created with either operator. Or
more likely, they'll tell you to read your C++ book more carefully, or get
a better book.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.



Relevant Pages

  • Re: Question on LSP
    ... We are talking about sibling subtypes in an existing tree. ... But that is not known until the Object Reference type is instantiated; yet the semantics of Object Reference must exist in the language meta-model prior to instantiation. ... A pointer points only to an object and messages are sent to objects. ...
    (comp.object)
  • cannot install p5-Apache-SubProcess on freeBSD 5.4
    ... mod_perl.c:235: error: syntax error before ')' token ... mod_perl.c:781: warning: passing arg 1 of `Perl_newSVpv' makes pointer from integer without a cast ...
    (freebsd-questions)
  • Pointers and Teaching C++ [was Re: A little disappointed]
    ... like Java where *many* facilities such as raw pointer access / manipulation ... are removed in order to create a 'safer' language and stop programmers ... then it is probably wiser to teach programming using ... pointer access / manipulation is not a 'high level language'. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: The Decline of C/C++, the rise of X
    ... > tend to be most useful for encoding Boolean values in data structures ... to freea pointer obtained from the gc, ... >> to be a useful attribute of a language. ... Template arguments are evaluated in the scope of the point of instantiation, ...
    (comp.programming)
  • Re: Obstacles for Tcl/Tk commercial application development ?
    ... And once I put an integer into a variable in Tcl, it stays an integer until I assign something else to that variable. ... Usually, when I code, I know the language well enough to know what types the expressions return, so I don't wind up with the wrong types in variables. ... It takes a char* as the second argument, not a pointer to the structure you're trying to write out. ... If I expect my code to pass me an open file handle, and I pass that argument to and it throws, I'm going to catch that error at the top level, log the stack trace back, clean up, and restart the processing. ...
    (comp.lang.tcl)