| |
| |
| |
|
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
<Nedds> wanted to know the position of the mouse-cursor.. <_kriz> i have a cl*** called Cat <einride> uhh in console? <_kriz> and i define a method called GetAge <_kriz> why can the compiler not compile :\ <Nedds> einride hehe yes <Nick_E> kriz <einride> well if you for some odd reason want the *mouse* cursor pos in console character coordinates... <_kriz> yeah? <Nick_E> let me see the line thats causing the error <einride> you'll probably have to start with GetCursorPos and then get the client area position <_kriz> int Cat::GetAge() <-- <einride> and start doing some math <Nedds> einride ok, i will try :) .. thanks <Nick_E> do you have a decleration for that function, does that line prefix an actual definition ? <einride> but what is it you actually want? <einride> the mouse cursor pos in screen coordinates == GetCursorPos <einride> what you are working with is the console character position of what microsoft named a "caret" <_kriz> Nick_E: http://rafb.net/paste/results/FkGmIA34.html <_kriz> i mean if it is in a c++ book <_kriz> the code should compile :D <_kriz> still here Nick_E? <Nick_E> yeah <Nick_E> not always though <Nick_E> put a semi colon at the end of your cl*** decleration <Nick_E> like: }; <Nick_E> works now ? <roods> when you have a non-reference to a boost::shared_ptr<T> in a method signature does .reset change the calling argument or only when it is p***ed via reference? <_kriz> ah works then thanks <_kriz> whats that semicolon doin there btw? <Nick_E> its supposed to be at the end of cl*** decleration <Nick_E> rule <_kriz> i c <_kriz> i thought that would be the } <_kriz> but oki <Nick_E> no, its different from a definition <_kriz> k <wilx``> *sigh* <wilx``> This teacher teaches bad C++ :/ <wilx``> using namespace std; in headers. <wilx``> Confusing function template specialisation with overloading. <job> i have yet to see a book that uses namespaces properly <markovich> namespaces suxors! <NKD> I generaly dont specify a namespace <job> i like namespaces <NKD> but i havent done much coding <NKD> nothing big either <markovich> I see no point in having namespaces for any project under 100.000 lines <markovich> namespaces is like a big organisational structure <markovich> if your project is small, cl***es are all you need for functionality organisation, you do not need umbrella namespaces <job> number of lines doesn't make a difference, i use it to split up my personal code library <job> i have a Parsing namespace, a Net namespace etc <NKD> Before I got my c++ book, i was trying to follow some tutorials online.. lol boy that was funny <job> Parsing::Split(string...) stuff like that <markovich> are the conflicts between the two namespaces? <NKD> imagine my surprise when their hello world didntcompile :P <markovich> what is the difference between Parsing cl*** and Parsing namespace? <job> markovich, you don't need a cl*** <markovich> unless of course you are going global <job> it's a single function <job> and i like to group stuff together into namespaces <markovich> so you are using global functions <job> yes, but in a namespace <markovich> I rest my case :) <job> it's to prevent naming conflicts <markovich> are you also using gotos? <job> err, what case? <markovich> just joking ;) <job> markovich, why add it to a cl*** <job> if i never instantiate it <markovich> I get your point job <job> heh <markovich> actually, that makes sense I must say <markovich> because some functionality just cannot be wrapped in cl***es <einride> like? <markovich> TimeToString <markovich> or Trace <einride> CTime(value).toString() <markovich> So I should make a cl*** for Time, when I use it only 6 times in my project? <einride> i would <markovich> I would have about 200 cl***es in my project then <einride> and the point is... ? <markovich> What about Trace <einride> Trace as in... ? <markovich> you want to put that in cl*** too <job> there's no point in making a cl*** unless you intend to persist the object over time <markovich> output debug <job> if you are just creating it and destroying it after calling one member <job> that's a bit pointless <einride> i use a cl*** for that too <markovich> einride: Well, that is inefficient programming <markovich> because <einride> hmm why? <markovich> 1. Memory and CPU cycles are wasted <einride> uhh they are now? <job> you are paying for construction/destruction <markovich> 2. It contributes no organisational benefit to your code <markovich> so why do it? <einride> not if the constructors don't do anything <job> memory is still allocated for the object <markovich> einride, still, you need to have that object in memory <einride> and you don't do that if you p*** it on stack to a function? <job> only the parameter is p***ed on the stack <markovich> and you are not allocating and immediately deallocating <markovich> function calls are efficient <job> at least make it a static method <job> then call <job> MyCl***::StaticFunction(...) <job> c# has pure static cl***es for example <markovich> but actually, for me the perfomance issue is not the critical one <markovich> the problem is simply that I do not want 200 cl***es in my projects <job> it just doesn't make sense to use a cl*** <einride> may i suggest that you actually verify your claims on inefficiency before stating them in public? ;) <markovich> I want to find what I'm looking for immediately <markovich> einride: let's forget the efficiency issues, I cannot back up my claims ;) <roods> sorry, i asked this earlier and didn't see a response. if i have a shared_ptr and p*** it by value what happens to the caller when i call .reset in the method <einride> so, let's see. struct Time { Time(int UnixTime) : FTime(UnixTime) {}; const std::string & toString() const { .... }; int FTime; } <einride> Time(3).toString() differs from TimeToString(3) how? <einride> 4 bytes on stack, one call. <markovich> my TimeToString function is TimeToString(double d, char* p) <markovich> I do not want or have a Time cl*** <einride> Time(3).toCString(char * p) <markovich> I just have my values in seconds <markovich> I'd be wasting my time to make that cl***, for no benefit I can see <markovich> when I can just make a C function call <einride> i prefer p***ing Time cl***es around. same memory/cpu cost, better type safety. <markovich> it's fricking seconds stored in a double <job> why not typedef then <markovich> what type safety issues are going to come up there? <einride> markovich: if i wanted to use the Time for anything but time i'd have to explicitly pull the int out. it will not happen by accident, variable renaming, whatnot <einride> the compiler will catch such attempts to misuse it <einride> not to mention, Time T(3); T.toString(); ..... T.toString(); // *less* cost than two p***-arg-on-stack function calls <markovich> einride: well, it is a programming philosophy question. I do not do things unless I can see a _clear_ benefit to it <wilx``> Hmm, yet another non-truth. <wilx``> foo x[3]={1}; doesn <markovich> in this case, I do not see any really convincing argument to make a cl*** with just one function <wilx``> 't "copy" the first element to initialize the rest :/ <wilx``> Bah. <wilx``> I've lost all respect. <markovich> I do not see why a single function should be wrapped in a cl*** <einride> markovich: as you said, philosophy. <markovich> yeps <markovich> let's shake hands and agree to disagree <einride> ;) <markovich> damn, you got me <markovich> alright, let me get back to my physics paper <strtok> morning h4x0rs
Return to c++ or Go to some related
logs:
x86-64 registers politics
|
|