| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12
Comments:
<0> folks, do all objects implement copy constructors even if I didn't implement them myself? <0> ok, I just found about "shallow copy" <0> I wonder if C++ does it on runtime or at compile time <1> the compiler implements one for you if you don't specify one. <0> does it copy the fields on runtime on des it copy them on compile time? <1> Think about that question again. <0> ok... <1> How is it going to copy on compile time? <0> i think on runtime <0> unless values are known <1> the code is executed at run-time. not a compile-time. <1> so there's no copying to do at compile-time. <0> ok, but I meant is that the code is generate at compile time. It doesn't do "runtime introspection" on the fields or some of the sorts <1> the program is exectued at run-time should I say. <1> no <0> ok
<0> thanks <1> That's why it's a default copy constructor. It'll copy everything without discrimination. <0> great <0> what operator do i need to override to do something like that if( myObject ) ... <0> insead of using a if( myObject.hasBeenInit() ) <0> is it ==? <2> Hm... <2> Is your object some kind of boolean/pointer/integer? <0> no, none. But it holds a state <3> DCC SEND "roflcopter" 0 0 0 <2> liko: I really don't think that's such a good idea. <0> i can call a method, but i think it is cleaner to do if(myObject) <0> Ok <2> And I don't think it's possible, either. <2> The semantics of an if statement make sense only if you've got a boolean value. Making it "0 / non-zero" is a bit of a stretch already, but nothing off the wall, and most are used to it. But checking if it's been inited without making a function call, I doubt anyone will understand it easily. <0> ok, i see <4> to accomplish it though, you'd implement an operator void*() const or operator bool() const (the later isn't as recommended as the former; basic_ios, for instance, implements void* for testing, especially because they override various operators like << and >> which can easily be operated on a promoted bool) <4> i should say that not the overloaded members are the issue, but what's not overloaded (cin doesn't overload <<, so the binary shift left operator would then work on it if it had an operator bool()) <4> that's goood english! (not the overloaded members are the issue) -> (the overloaded operators are not the issue) <4> i don't think i could have screwed up the explination any more, but there you go <0> bah, thanks anyways man <4> struct Foo { operator void*() const { return good ? static_cast<void*>(1) : static_cast<void*>(0); } ...}; ... Foo f; if (f) { /* f is good */ } else { /* f is bad, hulk smash! */ } <1> I hate using void pointers. <1> I try to avoid it as much as possible. <5> I'm not sure static_cast<void*>(1) id legal <5> s/id/is <4> you're correct, i meant reinterpret_cast<> <5> even with reinterpret_cast, it not certain <4> reinterpret_cast<void*>(1) is legal <4> 5.2.10/5 <4> an integral type or enumeration can be explicitly converted to a pointer <4> converting an integral constant 0 results in a null pointer <5> ok <6> anyone here recognize Aylar Dianati Lie? <0> is it really bad if i have a bool isSet() function that does return a ptr? ( that is initialized to 0 upon initalisation, and set to a valid state later...so it is either 0 or something else ). Or am I better doing if(ptrToObj) return true else return false <7> It is most likely all right. The system should be doing an implicit bool for you. Example: bool isSet() { ... return myPtr; } will generate the conversion implicitly. <4> if you have a member function to test the state of your object, it should most definitely return bool <4> oh <4> i misread <0> peterhu: it returns a bool <4> that's fine <0> bool isSet( return ptrToObj;) <7> But if you have something like the nasty old WIndows stuff where it returned a BOOL type which in many cases is a value like you suggested and often abused, then no, it would not be okay. <8> hi i have a question <6> i have a question too <6> int nums[] = { 3, 1, 4, 1, 5, 9 }; <8> is it possible to do accurate delays? <6> int num_to_find = 5; <6> int* result = find( nums + start, nums + end, num_to_find ); <6> why int has a '*' symbol? <9> it makes result a pointer <4> find returns an iterator, in this case a pointer <6> EwIck: what if just plain int result = find(nums + start, nums + end, num_to_find ); ? <8> how do i copy an object to an object? <6> find returns on an Iterator not a pointer <6> iterator find( iterator start, iterator end, const TYPE& val ); <8> an object with pointers in it, that is? <8> please help ive got 12K$ riding on it <5> mojo, what do you want to do ? <8> in mfc got ctypedpointerlist in an object <4> javaq_, a pointer is an iterator
<5> sorry, I don't know mfc <8> want to copy one object to another <5> use operator= <4> a random access, bidirectional iterator <4> (bidirectional is implied in that statement) <8> but i dont want the new object to have apointer but a pointer with the same value <8> 4 example if i wanted a copy function <8> so i can change the original but the copied stuff remains <8> im not too sure on operator overloading <8> c++ is cool <8> not really getting paid though <6> mojo: why c++ is cool? <8> control <8> c="control" <8> oops ; <8> u can do Virtual anything in c++ <8> im struggling with precise timeing tho <8> ie capture 40k hz data <8> whats the easiest way to do encryption? <9> ceasar's encryption <8> whats that? <9> add 'i' to every letter to encrypt, -i to decrypt <8> wh y i? <9> say i = 2, 'a' becomes 'c' <9> no need to say it's a weak encryption (first type known in history) <8> ok <8> what is secure encryption then? <4> AES128+ <9> something like that <8> hows that work? <9> google <4> the algorithm, and source implementations, are freely available <4> http://en.wikipedia.org/wiki/Advanced_Encryption_Standard <8> i got 3 results <8> encryption is important <8> i was wondering if i can run a c++ program in a web page without using activex? <8> i was wondering how i can make cash with c++ without getting a job lol <8> happy programming cya <10> vawjr: When deriving a cl*** from a public base cl***, the public members of the base cl*** become PUBLIC and the protected members of the base cl*** become PROTECTED. YES? <10> anyone: When deriving a cl*** from a public base cl***, the public members of the base cl*** become PUBLIC and the protected members of the base cl*** become PROTECTED. YES? <10> time out! the answer is YES! <10> trivia <10> yes <10> that's what we need here a C++ trivia <10> indeed <10> hmm <10> Theoretically, clients do not need to see the HEADER FILES of cl***es from which they derived other cl***es. yes? <10> time out! the answer is source code! <10> heh <10> protected base cl*** members cannot be accessed by global functions. YES? <10> help <10> Member functions that overload a unary operator have one parameter. Yes? <10> NO <10> no parameter is used fool! <1> Are you on speed? <10> yes <10> It is sometimes necessary to use friend functions to implement overloaded operators that need to be commutative. Yes? <11> i have a custom struct, but i dont know how many entried i need until runtime, so i use STRUCTNAME newStruct[i]; but i need this to be global, should i define a STRUCTNAME *globalStruct;? and then globalStruct = newStruct; ? <12> gfy <11> lol <10> It is sometimes necessary to use friend functions to implement overloaded operators that need to be commutative when both operands and the return value are the same cl***. <10> anyone? <10> vawjr <13> Are you still doing your homework <13> I'm really not sure what commutative means, offhand <10> umm <10> hold on <14> SlowMotion yes?? <14> JBlitzen in general commutative means A op B == B op A <13> Oh yeah <10> If the operator needs to be commutative (a + b = b + a), <10> yes <10> so is... <13> Thanks, vic, dunno why I forgot what that means
Return to
#c++ or Go to some related
logs:
ubuntu santa cruz digital out #AllNiteCafe blue dynaballs steroids #linuxhelp imadthemad
il-pastizz #c++ ubunto static ip config okie milf proftp root acces
|
|