RE: [Dev-C++] dynamic allocation and structs
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2002-10-25 09:44:06
|
Same answer as to previous mail. We were specifically talking about a C implementation. By the way, a vector is a vector in C, C++, Java, Fortran, Modula 2, Pascal, ... It isn't about the language, but about the concept. And it doesn't matter if I implement it myself, buy an existing library or have it built into the language. /Per W On Fri, 25 Oct 2002, Ioannis Vranos wrote: > > -----Original Message----- > > From: Per Westermark [mailto:pw...@ia...] > > Sent: Friday, October 25, 2002 11:51 AM > > To: Ioannis Vranos > > Cc: 'Dev-C++ Mailing List' > > Subject: RE: [Dev-C++] dynamic allocation and structs > > > > > > The trick is that vector isn't programming. It is a standard > > - and very > > old - mathematical term for a one-dimensional matrix. > > > Yes, but when we speak of C++ code, calling a built in array a "vector" > can only be confusing. > > > > > There has been > > millions of vector implementations before STL did a template > > version, and > > the probability of a finding a STL construct in a C program > > is not that > > high :-) > > > Yes, but it still can be confusing to C++ programmers. > > > > > > > While code might syntactically switch around between > > (*a).x, > > a->x > > a[0].x > > > > the third form is definitely dangerous to use when a is only > > a pointer to > > a single element. If there is an element zero, the logical > > conclusion is > > that there must be a element one. > > > Yes, if there is only one element i would use the -> only. When we have > more the [] is more suitable. Both are valid. > > > > > > > > While one goal of programming is to make the programs work, > > it shouldn't > > be neglected that comming generations of programmers > > inherriting old code > > does immediately see what the code does. When seeing a x[0] > > statement, the > > natural reaction is - or should be - to start hunt for the > > total size of > > the vector. > > > Yes. However i did created a 200x100 array on the free store so the > second [] was suitable. :) > > > Ioannis > > * Ioannis Vranos > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL: http://run.to/noicys > > > > ------------------------------------------------------- > This sf.net email is sponsored by: Influence the future > of Java(TM) technology. Join the Java Community > Process(SM) (JCP(SM)) program now. > http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |