| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11
Comments:
<0> do you have to do something special when freeing memory with delete in a templated cl*** <0> if i leave the destructor using delete [] ptr it crashes on ints <0> if i leave it as delete ptr it crashes on strings <1> well, just match your news with your deletes <1> new[]? Use deletep[ <1> er, delete[] <1> otherwise, idernet.org) has joined #c++ <1> [22:00] <0> do you have to do <1> sigh. My typing is all gone to hell, sorry <0> hehe <1> new[] pairs delete[]. new pairs delete <1> don't mix and match <0> how do I test a template type then <0> to see which to use <1> why would you have to? <1> if you allocated it with new[], you use delete[]
<0> what's the diff between new and new[] <0> & delete & delete[] <1> basically deals with allocation/destruction of more than one object at once (in the array returned) <1> don't forget, new and delete do more than just malloc ram - they deal with the constructors, destructors and housekeeping <1> if you new foo[10], you get back 10 nicely prepared and constructed foos <1> if you then "delete (new foo[10])", the behaviour is not really defined <0> elem = new T; <0> *elem = x; <0> is that perhaps whats doing it? <1> yes <1> wel <0> Node (const T x) : next(NULL), prev(NULL) { <0> elem = new T; <0> *elem = x; <1> depends on x <1> elem = new T; // Construct a T and ***ign a pointer of it to elem <0> right <1> *elem = x; // ***uming x is of type T, then copy x into elem <0> right <1> however <1> well, no, that should be OK. Where does it crash? <1> afk for moment - proof reading <1> someone else will hopefully pick up in my absense :) <0> on the delete <0> if it's a string, it'll crash with delete ptr <0> if it's an int, it'll crash with delete[] ptr <1> (still afk, but post your code on the site in the topic) <1> (also, unless this is homework, you're probably better off just using std::list or std::vector) <0> it's a project <0> no one has any ideas? <2> eci around here string means "std::string" nothing else <0> ? <0> i know what a string is <0> :) <1> post your code to the site in the topic <0> i may be on to something.. sec <2> then this is bull**** <2> <0> if it's a string, it'll crash with delete ptr <2> <0> if it's an int, it'll crash with delete[] ptr <1> templated code should be type agnostic - you shouldn't need to deal with delete[], or delete whatever, nor new[] or new <1> just new and delete, in terms of the type you were templated as <0> vaw? <2> those comments you made are crap <0> they're crap why <2> becasuse std::string* blah = new string <2> does NOT crash with delete blah <3> bye all G`night all <0> what does that have to do with knowing that "string" in #C++ refers to std::string <2> because IF you meant char* by mistake, THEN it might have been a correct statement <2> so either you misspoke or misknew <2> your call <0> i was explaining the behavior i was seeing <0> i didn't mis-speak <2> I don't believe it crashes on "strings" <2> btw, the simplest way to keep such a destructor from crashing, ***uming you really NEED to do a new[] for at least one case, is to do new type[1]; for the other cases <4> new and delete are evil. you shouldn't really have them spread all over your code. <2> Achamenes interesting bit of wisdom <2> and they are hardly evil...... malloc() and free() are evil though <4> OK, I agree that they're not evil in their essence... but they become evil when people don't know how and when to use them, and most don't. <4> It's very annoying to see people use new everywhere in the code, almost randomly, and then go on whining about how C++ does not have a garbage collector. <4> vawjrwrk: do you have much experience dealing with Unicode?
<2> Achamenes not very much, no <4> it's such a confusing topic... <5> Achamenes: Why is that anyway? <4> davsn: Why is Unicode confusing (to me)? <5> yeah <4> because there are a LOT of little details here and there, and it's not clear whether, say, the .NET implementation of it implements a given feature or not. <5> nope' <4> what do you mean?! <5> .Net has the regionalinfo cl***es to distinguish easily such stuff. <5> also the resource files can hold the different regional settings for the application. <4> OK, let's forget .NET for the moment. To C++ and MFC. <6> vawjr, I've got no ops here, can you unban EwIck, before I forget? <6> oh geeze <6> how'd you do that? <7> really quick typer <4> davsn: In MFC applications, you can set it to use "Unicode character set." But what that does is to change TCHAR to unsigned short instead of just char. <6> that's amazing <7> off again, later <6> you should have a tv show <5> yo TechRaven <7> yo davsn, i'm out of here ;> ttyl <2> Achamenes what compiler are you using? <6> you could have all kinds of adventures that revolve around your typing abilities. <6> like, in that one James Bond <6> where he keeps guessing p***words until he magically gets it. <4> vawjrwrk: VC++7.1 <5> heh <2> you MIGHT want to tell it that wchar_t is it's own type (which is the default in vc++2005) <4> vawjrwrk: What difference would that make? <6> well <6> typedefs really don't create a new type <5> Achamenes: it's for unicode. <6> they just give you a new name for a type <6> but the type itself is exactly what you typedefed it to. <6> there should really be something like a strict typedef or something <2> I concur <6> where you actually get a new type. <5> 6.0 even has it, vawjrwrk knows better then me of course. <2> and neither should you <4> davsn: See, that's exactly what confuses me. What do you mean "it's for Unicode"? <5> vawjrwrk: you are definetely right. <5> 2005 is great. <4> davsn: You can work with Unicode and use char. <2> Achamenes what is it you're wanting to do? <5> Achamenes: http://www.cppreference.com/keywords/wchar_t.html <4> vawjrwrk: I just want to make sense how Windows, MFC, and .NET deal with Unicode. (Even though, .NET is a lot better documented about its use of Unicode.) <4> davsn: I know what wchar_t is, but that doesn't make anything any different. The point is that you can use chars and Unicode together just fine. <4> am I making any sense here? <5> i don't see the point, why you feel so problematic with unicode. <4> the problem is not Unicode, it's how Microsoft uses the term and has implemented it that confuses me. <4> davsn: Unicode itself is not a text encoding, right? <2> Achamenes nope, you're not making a lot of sense <4> OK let me try again :) <8> hmm, filezilla is issuing some odd commands <4> Unicode provides us with a set of tables, a set of rules, and many different algorithms to store, interpret, and render text right? <8> like REST 0 constantly <8> is that it's way of keeping alive the connection? that's what NOOP's for <2> Achamenes I haven't seen the Unicode spec since around 1.1 <4> oh... it has changed a lot i suppose. the current version is 4.1, and they just released 5.0 beta 2, <8> pfft, everything should be ASCII representable! <4> in a nutshell, at least in the current version, Unicode itself is not an encoding scheme, it's just an abstract set of rules and descriptions of characters. <8> want some hiragana? ASCII art baby! <8> want some complex scientific symbols? ASCII art baby! <9> S THERE any function which evaluates the evalution time? <4> to encode text in unicode, that is to get a binary array representing Unicode text, you should use encoding schemes like UTF8 or UTF16. <8> use a high resolution timer, OS dependent <6> http://www.sfgate.com/cgi-bin/article.cgi?f=/c/a/2006/04/12/BAG3KI7INT1.DTL <6> "We're saying it's not OK to recruit on high school campuses, it's not OK to recruit on university campuses,'' Marla Zubel, a UC Santa Cruz senior and member of Students Against War, said. "In order to stop the war, you have to make it more difficult to wage war." <2> evet <4> not politics again :( <2> Noidea, c'mon, it's the Republik of Kalifornia <2> Santa Kruz for god's sake <6> it's all politics here.
Return to
#c++ or Go to some related
logs:
#chatzone malta isaac tattoo noorx dead rat alpha Boot floppy scott aki
irene dumalan #chatzone #linux #java #linux
|
|