|
From: Daniel G. <sp...@ho...> - 2002-02-17 16:49:55
|
<html><div style='background-color:'><DIV>
<P>I thought vecotrs were only used with graphics? Can you use them at other times?<BR><BR></P></DIV>
<DIV></DIV>
<DIV></DIV>>From: "Devin Carless" <DCC...@YA...>
<DIV></DIV>>To: <DEV...@LI...>
<DIV></DIV>>Subject: Re: [Dev-C++] 'New Source File' bug
<DIV></DIV>>Date: Sun, 17 Feb 2002 11:46:47 -0500
<DIV></DIV>>
<DIV></DIV>> > I currently have little knowledge of the standard library and i am
<DIV></DIV>> > currrently learning about it (currently reading 16 chapter of TC++PL
<DIV></DIV>> > Special Edition). But with as many as i know so far you can do many
<DIV></DIV>> > things with vectors:
<DIV></DIV>>
<DIV></DIV>> Oh, I know. They're wonderful-looking things. I'm currently only
<DIV></DIV>>using them as fancy dynamic arrays.
<DIV></DIV>> But while you can do a lot with vectors, vectors can do a lot with
<DIV></DIV>>you. I had Vec.size() in a conditional, and the conditional
<DIV></DIV>>consistently got it wrong. It worked, however, when I replaced
<DIV></DIV>>Vec.size() with a variable, Size, which had been intialized to
<DIV></DIV>>Vec.size() a line before.
<DIV></DIV>> That's only one reason I'm very cautious with vectors.
<DIV></DIV>>
<DIV></DIV>> > Anyway i think it is our lack of knowledge, not vectors. When i finish
<DIV></DIV>> > the 16th chapter i will resend an email telling you how you can to
<DIV></DIV>> > assignments using vector constructors.
<DIV></DIV>>
<DIV></DIV>> There's a saying that goes 'It's a poor workman who blames his tools.'
<DIV></DIV>>And many times it's been my mistake; I'm a poor workman. But there
<DIV></DIV>>are other times when I've caught something funny going on. (push_back()
<DIV></DIV>>refusing to work was one of them.)
<DIV></DIV>>
<DIV></DIV>> > I am confident that standard containers are better than built in arrays.
<DIV></DIV>>
<DIV></DIV>> Absolutely true: the reason I'm using vectors is because arrays are
<DIV></DIV>>/worse./ The only thing I think arrays have to recommend them is that
<DIV></DIV>>they can be intialized like so:
<DIV></DIV>>
<DIV></DIV>> char* frogs[4] = { "Green", "Tree", "Bull", "Muppet" };
<DIV></DIV>>
<DIV></DIV>> (Yes, I know char* is frowned upon, but I've found some interesting
<DIV></DIV>>traps trying to initialize a string to a string constant of the form "Blah"
<DIV></DIV>>when passed as an argument.)
<DIV></DIV>> For my project, in which certain subclasses have great tracts of
<DIV></DIV>>constant data, this kind of initialization would be ideal.
<DIV></DIV>>
<DIV></DIV>> > You can overload an operator as a global function
<DIV></DIV>> > e.g.
<DIV></DIV>> > vector<INT> &operator=(vector<INT>&a, const vector<INT> &b)
<DIV></DIV>> > { ... }
<DIV></DIV>>
<DIV></DIV>> Thank you :)
<DIV></DIV>>
<DIV></DIV>> > or better define it as a template:
<DIV></DIV>> >
<DIV></DIV>> > template <CLASS T>
<DIV></DIV>> > vector<T> &operator=(vector<T> &a, const vector<T> &b)
<DIV></DIV>> > { ... }
<DIV></DIV>>
<DIV></DIV>> Templates I'm somewhat wary of; I'll deal with them when I have
<DIV></DIV>>to. Until then I'll stick with learning the ins and outs of what I /do/
<DIV></DIV>>know.
<DIV></DIV>>
<DIV></DIV>> > Yes, me too. But C++ is 10000% better. I suggest "The C++ Programming
<DIV></DIV>> > Language" 3rd edition or Special Edition by Bjarne Stroustrup (the
<DIV></DIV>> > creator of C++).
<DIV></DIV>>
<DIV></DIV>> Unfortunately, that's beyond my resources. I don't have the money and the
<DIV></DIV>>demand in the university/city library for books that teach C++ is total.
<DIV></DIV>>I've
<DIV></DIV>>only managed to scrounge the texts I'm working with by good fortune.
<DIV></DIV>> And despite what I might say, C++ is 10,000% better. Partially, I think,
<DIV></DIV>>because the old Kernighan and Ritchie paradigm of 'only stupid people make
<DIV></DIV>>mistakes - are you a stupid person?' has been replaced by the strong-type-
<DIV></DIV>>checking 'Everyone makes mistakes, we'll help you catch them' theory.
<DIV></DIV>>
<DIV></DIV>> > It is better. :)
<DIV></DIV>>
<DIV></DIV>>You've said it three times now - it must be true!
<DIV></DIV>>
<DIV></DIV>>--Devin Carless
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>_________________________________________________________
<DIV></DIV>>Do You Yahoo!?
<DIV></DIV>>Get your free @yahoo.com address at http://mail.yahoo.com
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>_______________________________________________
<DIV></DIV>>Dev-cpp-users mailing list
<DIV></DIV>>Dev...@li...
<DIV></DIV>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
<DIV></DIV></div><br clear=all><hr>Join the worlds largest e-mail service with MSN Hotmail. <a href='http://go.msn.com/bql/hmtag4_etl_EN.asp'>Click Here</a><br></html>
|
|
From: Ioannis V. <no...@ya...> - 2002-02-18 07:36:20
|
Yes. Ioannis * Ioannis Vranos * Programming pages: <http://www.noicys.d2g.com/> http://www.noicys.d2g.com * Alternative URL: <http://run.to/noicys> http://run.to/noicys -----Original Message----- From: Daniel Glenfield [mailto:sp...@ho...] Sent: Sunday, February 17, 2002 8:30 PM To: no...@ya... Subject: RE: [Dev-C++] vectors Oh is it now? Thank you very much, I never learnt that on my course. ANSI C++ standard as well I assume? |
|
From: Benjamin W. <ben...@ho...> - 2002-02-19 13:43:26
|
<html><div style='background-color:'><DIV> <P>Good morning,</P></DIV> <P>It looks like this has already been answered so I'll make it short, my apologies..but I've been on vacation this past weekend and didn't get a chance to check mail.</P> <P>Anyway, there are "vectors" as they are known in mathematics and graphical programming techniques and then there are "vectors" as they are known in C++, which are just STL containers used, as Ioannis has already mentioned, to help handle situations where arrays break down and aren't quite efficient enough. They are a very good and useful tool.</P> <DIV><FONT face="Geneva, Arial, Sans-serif" size=2>Benjamin Wheeless</FONT></DIV> <DIV></DIV> <DIV><FONT face="Geneva, Arial, Sans-serif" size=2><STRONG>Network Systems - Delta Airlines, Inc.</STRONG></FONT></DIV> <DIV></DIV> <DIV><FONT face=Arial size=2><STRONG>Atlanta, GA - USA 30320</STRONG></FONT></DIV> <DIV></DIV> <DIV><FONT face=Arial size=2><STRONG>==============================</STRONG></FONT></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>----Original Message Follows---- <DIV></DIV>From: "Daniel Glenfield" <SP...@HO...> <DIV></DIV>To: dev...@li... <DIV></DIV>Subject: Re: [Dev-C++] vectors <DIV></DIV>Date: Sun, 17 Feb 2002 16:49:45 +0000 <DIV></DIV> <DIV></DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a href='http://go.msn.com/bql/hmtag_etl_EN.asp'>http://explorer.msn.com</a>.<br></html> |
|
From: Ioannis V. <no...@ya...> - 2002-02-17 17:33:33
|
vector is container of the C++ standard library aimed to replace built in arrays. Ioannis * Ioannis Vranos * Programming pages: <http://www.noicys.d2g.com/> http://www.noicys.d2g.com * Alternative URL: <http://run.to/noicys> http://run.to/noicys -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Daniel Glenfield Sent: Sunday, February 17, 2002 6:50 PM To: dev...@li... Subject: Re: [Dev-C++] vectors I thought vecotrs were only used with graphics? Can you use them at other times? |