« first day (26 days earlier)      last day (4913 days later) » 

12:13 AM
goodnight, in Norway
oh, ok, good morning! (in Korea)
afk
 
Good afternoon from Seattle!
 
Good afternoon from Portland!
 
12:55 AM
@tina i'm just dropping in. const T is a type identical to T except an added constraint, that objects of type const T can not be modified. Formally it's more subtle, and there are ways to work around constness, and there are surprise logical implications of the rules. But that's the short of it. It's designed to free you from worrying that something will be modified.
@tina A const after a method declaration applies to the type of *this inside the body of the method. And if you consider this as a sort of hidden argument, also to that hidden formal argument's type. And that affects what objects it can be called on (just the logical implications of enforcing non-modification of const things).
@tina T v(5) and T v = 5 have the same effect for fundamental types, but are subtly different for class types. The first is direct initialization, the second is copy initialization. For a copy initialization things work out as if an object of type T is constructed on the right side of =, and then the variable on the left side is direct-initialized with that temporary object (i.e., a T constructor is called with the temporary as argument).
@tina "can't" is a bit too strong but that's the intention, yes.
@tina now i'm off, first to 7-11 for some stuff... cheers!
 
ok, lets try and shed some light on this. the most consts you can through into a function would be const int* const MyDoubleFunction(const int* const) const
 
@tina no, on the contrary, sprinkle `const`as liberally as you can everywhere, though not on data members. that adds constraints on what values can be changing. and that means it's much easier to reason about correctness & figuring out what the code, or what it does wrong.
@tina now i'm really off... cheers
 
The very last const means that this member function will not modifie data with in the object, this is a fairly simpl one
 
well, make data members const when it makes sense — it just doesn't make as much sense as often as elsewhere
 
the const int* const that you see twice mean the same thing, it is a constant pointer to a conatant int. in other words the functions takes a pointer (and returns one) that will always point to same value that value of which can not change
I find this page really good for explaing how to use const
when you sue const on returned data it is usually because you are returning a pointer to a member value and do not want the external code be able to just change it at will. such as const int* GetWidth(); This is kind of pointless on a small value like an int, but it shows how you can return a pointer to the member data (so that the data does not have to be copied) and know that where ever GetWidth is called can then go on to edit the value of width
Finally, you can use const for the parameters that are passed in as a sort of promise that you will not try to edit the data is passed in, very commonly used with C style strings, which are just arrays of chars
I would say that properly applying const is good practice, especially when working with others or making code that will be used in a library by others. But you could get away with not paying much attention to it. bare in mind though, that trying to 'properly' apply const correctness into code that has not been written with it in mind can be a pain
any ways, night
 
1:32 AM
think of references as aliases
that parameter is an alias for some other object, and because it's non-const, it can modify that aliased object — this can be surprising when reading code
1
A: How to pass objects to functions in C++?

Roger PateThere are several cases to consider. Parameter modified ("out" and "in/out" parameters) void modifies(T &param); // vs void modifies(T *param); This case is mostly about style: do you want the code to look like call(obj) or call(&obj)? However, there are two points where the differenc...

per that answer, the choice isn't "non-const ref vs const ref", it's "do I want to modify or not modify?"
and once you figure out modification, you decide how it should be passed, which (for non-modification) is const ref vs by value
well, that's what I'm saying, "const vs non-const" is the wrong question
you're still thinking about const in the wrong order
1) does that function need to modify the argument? that is, should cDate have the same value before and after PrintDate(cDate)?
(and please pasting such long code snippets that mainly consist of blank lines)
right, #1 is no
so go to the "Parameter not modified" part of the answer I linked: stackoverflow.com/questions/2139224/…
and you see the second question to ask is "const ref or by value?"
(not "const vs non-const")
 
2:01 AM
@tina: please use a service such as pastebin.com for larger code snippets. on pastebin your code above looks like this. it even gets line numbers so easier to discuss! :-)
 
there are even handy links at the right for pasting
Oct 31 at 4:33, by Roger Pate
Paste at http://codepad.org/, http://ideone.com/, or here if short.
 
@tina re what I think is your question: if you have a correct program, then you can remove all const and it will still be correct. for a short time. namely until a maintenance programmer tries to change some code, and is not protected by const. const is for us humans, not for the computer.
@tina it's the same as C++ is for humans. we could do everything in C, or assembly language. but C++ lets us express things at a higher level, and it lets us express logical constraints in a way so that the compiler can check that we do everything correctly.
@tina as an example, the Python programming language doesn't have const. and so Python programmers spend a lot of time hunting down inadvertent modifications of various objects that shouldn't have been modified. :-)
 
.Net doesn't support const qualification.
That causes me much angst.
 
2:26 AM
Good morning guys and girl(s).
 
Good evening.
 
Yes. :)
 
@James: iirc, you had an opinion on [homework], chat?
 
 
2 hours later…
4:13 AM
just ask your question; even if no one is here or interested now, if you ask then it will be there for people to see and answer
what is "opps"?
 
4:45 AM
@tina "classes defined by macros", what exactly do you mean?
 
Every night this project sounds more terrifying than it did the previous night.
3
 
@james as i understand it tina is doing a project to learn c++, modeling and some geographical info system stuff, on her own, using only web access (no books, no one else to help), although the GIS may be just a concrete example she's picked.
@james and if i've understand that correctly, it's natural that she's sort of all over the place, mixing fundamental and derived concepts and so on, because the structure of the knowledge is simply not apparent to a learner coming from outside and lacking guidance. for that matter, it isn't all that apparent to us! <g>
 
@alf: don't forget the youtube video tutorials
@tina: macros are evil. they exist outside of everything else and work on the source code at a pure textual level
@tina: if this is code you're writing, delete it now. if it's code you're reading, delete it now and scrub your brain.
 
(macros have valid uses, trying to figure those out now at your stage won't help you)
 
4:54 AM
@AlfPSteinbach I agree. Without a good book and without taking the time to learn the fundamentals before digging into complex things (like a GIS project), it's easy to get mixed up. It's so easy to get mixed up and to start down the wrong track that, as Roger pointer out last night, she is setting herself up for failure.
 
I've started saying "don't" much more often these last few years
I don't know if that's because I'm more comfortable having more experience, or some other conceptual shift
 
@tina: regarding the data member, it's just a data member. a class is just a type, like any other type. when you use a type it introduces a dependency on that type, yes, but UML diagrams would be unbelievably cluttered if one were to express all those implicit dependencies directly.
 
6:05 AM
#include <stdio.h>

int main(int argc, char *argv[printf("Hello, world!\n")]) {}
error: expected constant expression in visual studio 2008.
Can any one explain me.
 
@Arman: printf() is a function call. A function call cannot appear in a constant expression. The size of an array must be a constant expression.
 
11
Q: C Code: How does these even work?

Milan RamaiyaI just saw this here #include <stdio.h> int main(int argc, char *argv[printf("Hello, world!\n")]) {} What this does is print "Hello World!" But what's actually going on here? The best I can guess is that it gets compiled and thrown at the top of the execution stack, but the syntax doe...

Please check it this question.
 
C99 allows for variable length arrays; I don't know whether they are allowed in function parameter type declarations (I don't know why you'd want to use one in a parameter type declaration...).
Regardless, Visual C++ does not support C99.
 
 
1 hour later…
7:15 AM
@JamesMcNellis c99 has VLA parameters using [*], there's also sized arrays by specifying 'static' within the brackets
 
@tina do you mean you don't know how to use UML to show a class has a function called intersect or you don't know how to use UML to show how the function uses UML?
also, why are you so determined to mirror everything in UML?
It would be so much easier for you to learn C++ then learn how to describe code that you now understand in UML
 
7:30 AM
@tina do you mean test it?
in that case, why don't you ... test it ?
 
7:52 AM
If you wanted to write how the code for a function works, you would almost certainly want to use pseudo code.
You do realise don't that you UML is meant to be used for DESIGN before you write the code rather then trying to reverse engineer it from code (though you might have to do this if your team takes on an old application)
 
Als
@Tina are u reverse engineering and doccumenting the design of existing code?
 
yer... arse backwards but what ever.
@tina wait... your going through the call stack? why? you have the source code, just read it though and see what functions are defined, what calls are made where. You shouldn't need to use debug tools to document what is going, just read the code!
 
Als
@tina: If you are not aware of the source code then it is a good idea to put breakpoints in part of code you where know the control is going to come and then check stack to see sequence of the calls
 
yer, but just read the source code. Look at the main function, this is where your application will start. document what function calls it is making, don't delve into what these functions are doing. just worry about what the main function is calling.
THEN explain the first function that main calls, using the same approach
don't try to delve down into the nitty gritty detail, use the fact that code can be abstracted. its ok to say during the explanation for a collision detection on a large model that you just 'check triangle intersection' with out explaining how that function works. at a later point you will explain that function of the triangle class.
well, are you really going to explain the triangle intersection function every time it gets called?
in every place that it is called, does it make sense to explain how it is done? would you explain how addition works in every place it is used? No, you just take it as a function that has been defined
Why do you think we write function in the first place? so we can re use code and because we don't need to see how an algorithm works every time we use it
A child playing with wooden bricks, he takes those bricks as a given, he does not need to worry about how to make the bricks. He gets to enjoy playing with the brick as it is. The person who made the bricks does want to know every time some kid starts playing the bricks
i'll try.
say you are trying to explain some one something like... how to do an X^Y
the code would some something like
result = X;
for (0 to Y)
{
result = result * X;
}
you wouldn't explain the multiplication would you
you would take it as a given
it is also and more crucially, going to be used in other places, so you don't want to waste time explaining how multiplication works ever where you use it
@tina what? try that one again?
 
user69820
8:33 AM
I know netbeans has a tool that reverse engineers UML from existing code in Java. It might do this for C++ too, if that's what you're trying to do
 
9:13 AM
@thecoshman: did you see how this answer was off track?
 
 
2 hours later…
11:43 AM
can you initialize a member of a base in the derived class ctor?
 
12:01 PM
no, you pass a value to a base ctor
 
oh, and that will automatically be called each time a new derived is spawned?
 
a ctor for all bases are always called; but you can control which ctor that is in the derived ctor's initializer
struct B { B(); B(int); }; struct D : B { D() : B(42) {} D(int n) : B(n) {} };
struct E : B { E() {} }; // this uses B()
 
12:35 PM
can a base virtual destructor delete a pointer member?
 
12:53 PM
@Tony as long as the data member belongs to that base or one of its bases, sure; a pointer is just a value
@tina: I think you'd get more help with UML diagrams somewhere other than here; we just don't seem to be interested
 
 
1 hour later…
sbi
1:55 PM
status-declined
2
Q: Per-user setting for Feeds in the Chat

sbiI prefer to have that Feed guy throw in messages rather than that subtle "extra area on the screen". (That's because this makes it show on my browser's title bar.) Others rather like the opposite. So can we make this a per-user preference rather than per-feed?

 
why does deleting a char* const fail?
I want to delete a const pointer to a char but my program always hangs after doing delete.
 
Don't be vague, be an ace; write a proper test-case!
2
@Tony: not enough information to say anything, as what you describe works
 
there you go... the point of failure I have put a comment
 
@sbi :( I kind of thought the extra UI complication (and thus confusion for some users) would lead to that
(I think it'd be a nice feature for power users, though)
@Tony: why are you deleting the pointer? you never new it
 
@RogerPate this code is just part of an excercise for the book I'm reading... it is not production code, so just to let you know
 
2:02 PM
well, just like for any "homework" question, the process for asking and answering is the same :)
 
lol
 
using delete[] on a pointer you didn't new[] is UB
 
I see
but in this case I don't need to explicitly new it, if I'm passing it through a ctor
or is that just my bad practise
 
yeah, the string literal (which gets converted to a char const*, or the deprecated conversion to char* that you use) doesn't need to be manually allocated — but you simply can't manually delete what you didn't manually allocate
const doesn't change anything here
also, realize char const* and char * const are different types
 
first is a pointer to char const and second is a const pointer to a char? or opposite... always get them confused
 
2:06 PM
the former is correct
read from the inside out, starting at the variable name (or where it would go)
char const *p; // p is a pointer to constant chars
char * const p; // p is a constant pointer to chars
(silly me, used to irc to press up to get a copy of my last message)
char * const (*f(int))[3]; // f is a function taking an int and returning a pointer to an array (length 3) of constant pointers to chars
fuck, I did it again
char * const p[3]; // p is an array (length 3) of constant pointers to chars
 
@RogerPate thx :)
 
pointers and references to arrays are fun
 
@tony: use std::string.
3
@roger: did britney spears really sing that?
 
@AlfPSteinbach Yes I know I have to use std::string, but I'm learning pointer intricacies, so therefore the old style char*
 
@tony ok. in addition to what @roger says, for simple declarations you can simply read them backwards. like char const * const p backwards says "p is a const pointer to a const char". course for that placement of first const should be by the general rule...
 
2:16 PM
@Alf: who?
I dislike the "backwards" rule because it breaks with arrays and functions
 
@roger: jeez, don't u read the gossip columns? the lady who hung out with Paris Hilton, showing glimpses of you-know when getting out of a car?
 
sbi
@RogerPate Well, that brings us back to my original request:
 
so why have I got a feeling that pointers are not very popular with many programmers, or am I wrong in saying that?
 
sbi
yesterday, by sbi
BTW, would you guys object to having the feed throw in messages again instead of that overlay thing at the top of the chat window?
Feeds would have the advantage that they change my browser's tab's title, making me see that there are new messages with a glance at the task bar. I think I would like to have new questions be shown this way
 
@sbi: I suppose we can try it, but if it gets too noisy so I think it's disrupting chat, I'd strongly prefer to change it back
@Tony: C's raw pointers are used many different ways, and that can be confusing on top of learning the concept of indirection
@Alf: sadly, wikipedia does not have that picture
 
2:21 PM
0
Q: Moving the mouse pointer in C++ fails on Linux

OvervI'm using the following code to hide and show the mouse cursor: XDefineCursor( m_display, m_window, show ? None : m_hiddenCursor ); XFlush( m_display ); That works fine. However, when I run this: XWarpPointer( m_display, None, m_window, 0, 0, 0, 0, x, y ); XFlush( m_display ); The mouse ...

 
sbi
2:32 PM
@Robert Thanks!
 
0
Q: C++ compiled application

RodneyCan someone explain in a "very layman's terms" what a C++ compiled application is? There are network accessible computers which run some type of installed program/applet (for lack of better term) to access it across the network but it does not use http/https. Any assistance is appreciated just ...

 
if those Feeds posts could be smaller that's be much better :(
 
0
Q: ADL (argument-dependent name lookup) question.

Armen TsirunyanHi, I have something like this: #include <iostream> namespace N { typedef std::pair<int, double> MyPair; std::ostream& operator << (std::ostream& o, MyPair const & mypair) { /// } } int main() { N::MyPair pr; std::cout << pr; } Thi...

 
see what I mean about disrupting chat? and it's not even busy yet
 
well.. it can hardly disrupt chat that is not happening, but I do think the little pop up window thing is better
 
2:40 PM
I think no feeds be even better :)
 
sillyquestion: somehow i get them feeds showing up (probably by clicking on a link earlier), how to turn it off?
 
@Tony: you can ignore Feeds when posted as messages, but we can't have both the dropdown and messages for the same feed
 
true
 
@Alf: we just changed the room setting to try it out for sbi
 
I like it how there is a user Feeds
@Feeds are you just a bot? LOL
 
2:44 PM
/nick Feeds
uh, what?
 
0
Q: OpenCV RGB Value Detection?

MercfhSo im basically either looking for code, or even a sample to detect RGB values (maybe even with hue) to be used with OpenCV Ideally you would be able to show an object in front of your webcam, then click on it with it outputting the RGB values. Im trying to do this because im trying to find a d...

0
Q: Writting into a text file without overwritting it

Tom83BI'm doing a numerical simulation of gravity in C++ and I want to back up my results every time a single step is counted. However, the way I do it now, the programm always overwrites the file. I guess I would be able to solve in by always saving the text in a different file or variable, but I wond...

 
i think the feed could become Really Annoying(TM) with just a little more activity
 
Yer, it does very much depend on the trafic
 
1
Q: qt write to end file

shkHello, I need to write some text at the end of txt file. But i can only rewrite all file. How can i add text to the end of file? Thank you.

 
if the feeds started to come so fast that you can't read the actual chat, it will have to go
hmm... lets say I have a triangle class... could I and, and probably more importantly should I, overload the [] operator so that I can say myTri[1] to get a vertex... posibly take it as far as myTri[1].SetValues(1,1,1);?
 
2:56 PM
@thecoshman: you could. whether you should, q is whether it supports typical usage
 
erm... well... erm... does it :S
I think it dosen't for a triangle...
I might make a SO question for this one
 
@thecoshman: resist operator overloads
 
@tina: it just occurred to me that i've seen a question about GIS system classes generated by macros before. it was in connection with the system being ported to the Mac. if you're re-engineering an existing system, and if that is the system (can't be too many of those monstrosities around), then possibly the purpose is not to describe the C++ code, but rather what it achieves and how, like general, with the goal of re-implementing it in more sane way
 
0
Q: Creating string with libxml2 (c++)

leshkaHi. My problem is that I want to create xml tree and get a simple string object (or even char*). And I can't save xml to file. So in the input I have xmlDocPtr with complete xml tree and want to get string containing xml but without using files. Thx for attention.

 
@RogerPate yer, im thinking I shall just go for myTri.getVertex() method
 
3:09 PM
1
Q: How do i write a struct to a file using fwrite

mollemanHello , very new to c, and i am having trouble with frite im looking to use a struct that holds two values struct keyEncode{ unsigned short key[2]; unsigned short encoded[2]; }; i then declare my struct and a pointer to that struct in my main struct keyEncode keynEncode; struct keyEncode *s...

2
Q: How to understand the output?

ollydbgint main(int argc, char** argv) { try { char *p2 = NULL; cout << "p2:" << strlen(p2) <<endl; cout << "mark"; } catch (...) { cout << "caught exception" <<endl; } return 0; ...

2
Q: Dangers of converting delegates to function pointers.

insipidSuppose you have a managed class that converts a delegate member to a native function pointer and hands it to native code. Assume that the class/delegate stays in scope and does not change for the lifetime of the native code (so that will not be obviously destroyed by the GC). What other proble...

0
Q: Vector of Structures

RobertI have some code given to me by another person in which we have a structure struct Pair { string s1; string s2; bool equivalent; }; Then he sets up a vector of these structs hard coded std::vector<Pair> PairID; staticdata() { PairID={{"string","string2",true}, ...

0
Q: Choosing between set<int> vs. vector<bool> vs. vector<boolean_t> to use as a bitmap (bitset / bit array)

MartinGiven a range of indexes (identifiers), where I want to map each index to a boolean value, that is: // interface pseudocode interface bitmap { bool identifier_is_set(unsigned int id_idx) const; void set_identifier(unsigned int id_idx, bool val) const; }; so that I can set and query for eac...

 
sbi
@Roger Ok, Ok, since we now have much more elaborate feeds than when this was turned on first, I (grudgingly) have to agree that the sheer mass is annoying.
I turn it off again.
 
@sbi thx
 
3:26 PM
@sbi: I am sorry we can't have both
 
sbi
@RogerPate Me too.
 
3:59 PM
Wow
Post Overflow!
 
huh?
 
@Tony: the Feeds you probably ignored :)
 
4:22 PM
haha :)
 
@sbi: I think armen realizes that, he said vector<bool>::iterator can't be a bool* (context for everyone else:)
0
A: How can std::bitset be faster than `std::vector<bool>`?

Armen Tsirunyanthe vector accesses its elements with iterators, which can't be a simple typedef for bool*, , which makes it slower than bitset, which doesn't provide iterators. Another thing that makes it fast is that its size is known compile-time and therefore it does no allocation with new, which is slower t...

 
sbi
4:44 PM
@RogerPate Yep, I guess I hadn't read thoroughly enough.
 
5:31 PM
Heh. I had chat open on four different PCs that I was remoted into... there were 299 unread messages on this one :-P
 
lol
 
 
3 hours later…
8:59 PM
Question time :D If I have an octree and want the root node to be able to... self root... ie, make it self a child node of a new root node... how would I go about this?
 
you want to make it a child of itself?
 
Neil Butterworth memorial ... can anyone explain?
 
He died
^ That's not true, sorry. Bad sense of humor.
 
sbi
@John I think this started with this posting:
40
Q: Setting up a FAQ for the C++ tag

sbiA while ago Neil Butterworth, one of the most highly reputed people in the C++ tag (he has given so many good answers, that in the two months since he left, his defunct account has amassed >2000 rep from old answers), left here, obviously in frustration about Stack Overflow. I have since heard a ...

I'm not sure it's a good idea to still have this in the room's title.
 
@CiscoIPPhone no, I want to make a new root node for it to become a child of
 
sbi
9:08 PM
I mean it was a nice joke for a while.
 
thanks
 
sbi
@Roger @John @James @Jerry Maybe we should take Neil out of the room's title? What do you all think?
 
@sbi phft no! It's legacy dude
picture the day way in the future when people just accept that it just is the Neil Butterworth memorial, "whats with the Niel thing?" "ooh, that. Erm.. it's just always been"
When you define an enum, if you gave a one of the names a value, all following names are just one more then the previous. is their anything stopping me from having two names in an enum the same vale such as
enum direction{ top,bottom,left,right,T=0,B,L,R};
 
sbi
@thecoshman I never cared that much for Neil.
Nov 1 at 8:32, by sbi
@PrasoonSaurav I don't know anything about Neil, except what was made public. As I've written in comments to answers to that question on meta (http://meta.stackoverflow.com/questions/68647/setting-up-a-faq-for-the-c-tag) I don't even particularly care about Neil. (ISTR once flagging him because his attitude was worse than impolite.)
Oct 29 at 20:29, by sbi
@HostileFork Neil had been a long-time regular in comp.lang.c++.moderated before he came to SO, and is said (I didn't know that) to have left there more than once. I'm not moaning that much that Neil left (he could be quite rude at times, although his contributions were on a high technical level), but fear that other highly reputed users might also leave for similar reasons. Some of them have expressed similar resentments.
Nov 1 at 8:39, by sbi
@PrasoonSaurav I dunno. Maybe he'll come back, maybe he won't. I don't know Neil personally, so I' unable to care about him personally. I do care about his expertise being gone, though.
 
@sbi Probably a good idea.
 
sbi
9:22 PM
@James Ok, thanks for your feedback. I'd like to wait for one or two more opinions from the other owners, though. I wouldn't want to step on anyone's toes.
 
@sbi Too late. I already did the potential toe-stepping.
 
sbi
@James Well, that's fine by me. As long as it wasn't me who will get blamed, I couldn't care less about other people's toes. :)
 
AGHH! What behaviour is defined 0_o
 
@sbi What's the worst that could happen? Roger gets irritated and retags 500 of the questions I answered? ;-)
 
sbi
@James He'd do this in under 20mins, I believe. :)
Naw, I just don't want to cause any editing wars.
@thecoshman By definition it's always that behavior which isn't undefined.
 
9:34 PM
@sbi what behaviour isn't undefined
 
Behavior that is well defined or implementation defined.
 
hmm... think I might go for just one more... whats well defined?
 
Well-defined behavior is behavior that is defined by the standard. So, if you compile code that is well-defined, it will work correctly on every standards conforming compiler.
 
sbi
@thecoshman I just told you. Why are you asking again?
 
@sbi sorry, just in one of those brain fart moods
 
9:51 PM
@thecoshman type "c++ committee" in Firefox address bar, download a draft of the standard. terms like "undefined behavior" and "unspecified behavior" are defined at the very start somewhere.
 
sbi
23
Q: Undefined, unspecified and implementation-defined behavior

ZolomonWhat is the difference between these three?

 
erm... I was joking about this on account of the new room description...
@AlfPSteinbach firefox? phft, chromium
 
@thecoshman I think you may be right now, but when chrome was new i checked it out and it had no good adblock. i'll check that again. most urgently i need a replacement for moronbird. problem is i'm using an extension i made myself for mod work. i'd hate to have to create that again for other mail prog.
 
@AlfPSteinbach in terms of pop-ups, not an issue for me. though I never really found my self on sites with epic amounts of pop ups on FF or O
 
@thecoshman another reason at that time was google's malware-like updater. they had to fix it, but it was only half-heartedly (very political, pretending to make it open source while requirement to use same ole infrastructure).
 
9:59 PM
The latest draft is linked to from the C++0x tag info page as well.
 
@thecoshman when i get rich i'll go Mac. no adobe or google or microsoft updater there. i believe...
 
@AlfPSteinbach no, just over priced under performing shite
@JamesMcNellis nice
 
 
1 hour later…
user502230
11:09 PM
hi
 
11:28 PM
hii
 
11:55 PM
so this might be a dumb question, but why is this deprecated?
char* p = "hello!\n";
 

« first day (26 days earlier)      last day (4913 days later) »