Help Logs Database

Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Ircnet  |  Dalnet
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

<jamesd-> info: oh, drop the leading static. I made a mistake.
<jamesd-> WhatAHam: nope, I can't.
<WhatAHam> yeah drop the leading static..
<WhatAHam> static outside of a cl*** declaration means something completely different due to the weirdness of having to be compatible with C
<snibril> why you wrap list<> intgo a convoluted cl*** is beyond me.
<snibril> size i superfluous, it'S elems.size()
<infohunt> jamesd: still a 'cannot call member function ... makeIt' errormessage ....
<WhatAHam> oh makeit neads to be static
<snibril> with teh distinct advantage of it having the correct value
<WhatAHam> because there is no 'instance' of Date
<WhatAHam> or yuo can do Date().makeIt() if you want when you initialize the vector..
<jamesd-> infohunt: you'll need to give the full name of that function.
<WhatAHam> no.. the problem is he's calling a nonstatic member function without an object..
<jamesd-> infohunt: as WAH says, make the function static, or even a non-member.
<WhatAHam> infohunt, or, if you want.. use pointers to vector and use the singleton pattern in the Date() constructor..
<jamesd-> calc evil singletons
<CalcMe> no entry for "evil singletons"
<jamesd-> Should be.
<WhatAHam> heh singletons are evil?
<WhatAHam> since when?
<jamesd-> Since globals have been evil.
<Kniht> calc fancy global
<CalcMe> fancy global = singleton
<WhatAHam> bah globals aren't evil.. you just haev to know how to manage them
<WhatAHam> anyway you can have singletons without glow-balls
<WhiteWolf> http://pastebin.com/409369 <-- at line 12 when i=1, and j=0, I get a memory error... suggestions?
<Kniht> a singleton /is/ a global
<WhatAHam> yes.. but you can initialize them piecemeal as static members, etc.. it's naive to make the blanket statement "singletons are evil"
<WhatAHam> they are evil only to the naive
<snibril> Kniht: no. you can also use a factory pattern to ensure singleton-ness
<jamesd-> WhatAHam: many people with many years of experience have found that globals cause too many problems, too much of the time, and are rarely a win.
<WhatAHam> eve thougth singletons will ultimately live in the BSS section.. they are still not really 'globals' in the cl***ic language sense if you hide them in a factory
<infohunt> ok .. adding the Date(). in front of my makeIt() works ... thanks a lot for your endurance, jamesd and whataham !!
<jamesd-> snibril: if it's globally accessible from a factory, it's still a global. if your factory is accessible only within a certain scope, you've avoided *most* of the evil of singleton.
<WhatAHam> jamesd-, that's an argument i don't necessarily accept. many people with many years of experience dosn't mean **** to me.
<snibril> with the advantage that it is a feature of the factory that it returns always the same object (or a handle to such), not of the cl*** itself
<jamesd-> infohunt: making the function static is a nicer solution if it doesn't use the state of the object.
<snibril> which tremendously eases testing, f.x.
<jamesd-> WhatAHam: your claim that only the naive find globals evil was a personal slur on people whose level of experience you don't know.
<WhatAHam> it's naive to say the singleton pattern is evil.. there are uses for it.
<galbi`> oh man i thought i2 was 12
<jamesd-> WhatAHam: it's not naive, it's a slight oversimplification.
<WhatAHam> jamesd-, that's possible.. i apologize for the slur.
<jamesd-> Apology accepted.
<WhatAHam> it's like saying "don't EVERY use arrays in C++ because you are too stupid to understand them"
<infohunt> jamesd: ... then i get 'cannot declare member function `static' ...
<WhatAHam> erm EVER*
<jamesd-> infohunt: you have to declare it static in its original declaration but *not* in the definition.
<_m_> WhiteWolf: operator precedence.
<snibril> the real problem with singletons iss >NOT globalness
<jamesd-> WhatAHam: no, it's more like saying "avoid C++ arrays, they're crufty". When we mean "usually avoid them, unless you have a good reason why you need to use low-level tools".
<WhiteWolf> _m_: ?
<WhatAHam> infohunt, welcome to the confusion that is c++.. static has 2 meanings..
<roopjm> 2 meanings? wow
<WhatAHam> jamesd-, ok, that's a good, refined argument. but the singleton thing of saying "never use them they are evil" is an oversimplification, as you said.
<infohunt> jamesd: now i got it ... have to think about this solution guess for the next 2 weeks ... searching for it took me 2 days ... asking for it 20 minutes ....
<_m_> WhiteWolf: [] has higher precedence than dereferencing.
<bargeld^> join #ytmnd for free ops!!!!
<galbi`> is the first element of an STL list 0 or 1?
<bargeld^> join #ytmnd for free ops!!!!
<snibril> it's the fixation of the "you can only create one" into the cl*** interface ittself.
<galbi`> lol
<WhiteWolf> _m_: do you think i mean (*this)[i][j]?
<WhatAHam> galbi`, in all C-like languages arrays and array-like objects are indexed at 0
<WhatAHam> galbi`, it's the convention
<jamesd-> galbi: indexes start at 0, for arrays, random access containers. list doesn't have indexes.
<WhatAHam> in other languages they are indexed at 1 perhaps.. but not in c-like languages
<_m_> WhiteWolf: probably
<WhiteWolf> _m_: *nods*
<galbi`> hmm
<WhatAHam> but yes, std::list isn't indexible.. although other libs may give you indexible lists it is a bad idea to reference a non-random-access container randomly..
<xdank-> the term index implies random access-ness?
<galbi`> in the code, the for loop starts at i =1
<galbi`> <= 5
<roopjm> what're the 2 def's of static?
<xdank-> index 5 could just mean "5th element"
<jamesd-> xdank: for C++ standard containers it does. They only provide indexing if it's constant time.
<galbi`> why is the list size 6
<galbi`> instead of 5
<jamesd-> xdank: index has no meaning to std::list.
<xdank-> oh I'm not saying it does
<WhatAHam> well it has no meaning because they chose not to let you do expensive operations.. but other libs have indexible lists and you should know they are not constant time operations
<jamesd-> roopjm: static can mean "internal linkage" or "cl*** member, not object-specific".
<WhatAHam> although std::list::size() is a questionable thing to have put in there..


Return to c++
or
Go to some related logs:

metal
beginner

Copyright © 2005 www.irclogs.ws. All rights reserved. » disclaimer » contact