« first day (668 days earlier)      last day (4280 days later) » 

12:03 AM
what is the difference between doing #define STRMAX 599; and making a global int int STRMAX = 599;
 
Curiosity rover having firmware updated remotely... wow... good luck with that....
@MohamedAhmedNabil the global creates a variable that takes memory and can be modified, while the #define is just a "text substitution" done by the pre-processor that replaces STRMAX with 599 in the source code before it's compiled.
 
oh thank you
which in your opinion is better to use
 
you're welcome
If you don't intend on changing the value of STRMAX during run-time, go with the #define.
 
ok great info
how did you learn C++?
 
I'm not really good at C++ yet. I'm still learning by reading a book and doing practice problems. I've been a C developer for many years though.
 
12:08 AM
what do you think about strtok then
 
It has it's uses in C. I'm sure C++ has something this is safer to use.
 
one thing
when i do this for example
p=strtok(cStr, " ");
it finds the first " " changes it to null and then send the adress of the first token right?
 
correct.
 
but if i do the same thing again
p=strtok(cStr," ");
it sends the first token again
althought the " " no longer exists because it has been changed to null
 
That is why the subsequent calls have the first argument set to NULL.

/* strtok example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] ="- This, a sample string.";
  char * pch;
  printf ("Splitting string \"%s\" into tokens:\n",str);
  pch = strtok (str," ,.-");
  while (pch != NULL)
  {
    printf ("%s\n",pch);
    pch = strtok (NULL, " ,.-");
  }
  return 0;
}
 
12:13 AM
i know it is set to null
but why does this happen when i dont
 
Because that is the behavior of the function. :-)
 
although the first delimmiter has been changed to a null, it still sends the first token
strange
:S
 
Because if you keep passing it the beginning of the string, it will of course keep finding the same first token...
 
although the first delimmiter " " has been changed to null?
 
Yes... because then the string ends at that NULL leaving only the first token in the string.
The stuff after the NULL is no longer considered part of the NULL terminated string.
 
12:16 AM
i know
but i thought if the strtok doesnt find any tokens it returns null
wait a sec wait a sec
listen me out here
 
listening
 
it returns null when i send it like this this `strtok(NULL, " "); because the first element is null
argument not element
 
yes.
 
but here the first element is cStr strtok(cStr," ");
so it returns cStr
Am i correct?
 
Well it will return cStr up to the first " ". Yes.
 
12:20 AM
Im a genius
:D
 
cStr = "This is a test";
after call to strtok(cStr," ")
cStr = "This";
 
Then if you want to find the other words, you would call strtok(NULL," ") until NULL is returned.
See, you understand it.
 
but if there is no delimeter the first argument is returned
so "Thisisatest" has no space in it
to it gets returned
that why when I do strto(cStr," "); it stops testing at the first NULL because that is it's end and it return the first argument
 
If no token is found it will return NULL and leave the string unchanged.
str = "Thisisatest";
strtok(str, " ") return NULL
and str still equals "Thisisatest"
 
12:25 AM
i just tested that
it returns str no Null
it only returns null if null was the first argument
 
Well, that isn't what the man page says it should return.
 
test it out
yep it returns str
 
Ok I will test it and see what happens.
 
:D
im using C++
 
It might behave differently in C++. Let me see what it does in C.
 
12:29 AM
cppreference.com and cplusplus.com are great refrences for C++ and C
the first website only has C
the second is C++ only
 
Well, my test shows that NULL isn't returned.. perhaps that page documentation is incorrect.
 
we are masterminds
WOOOW
 
The man page is not clear about the return value if token isn't found once in the string. But no problem, a little test makes it clear.
RETURN VALUE
The strtok() and strtok_r() functions return a pointer to the next token, or NULL if
there are no more tokens.
I guess that isn't super clear.
 
no more
suggesting the next time you use strtok
 
yes, that is a valid interpretation. I'd like to see the man spell out what happens if the token is never found.
 
12:35 AM
:D
thats something new that u discovered
 
Yep!
 
that is always why i like to take matters like that into my own hands
:D
always testing myself
 
We are lucky if we can learn or clarify our understanding every day.
 
I always try to figure out how things are working on my own and come here for confirmation
great thing to do
 
Well @MohamedAhmedNabil nice chatting with you. I have to run along now and see my wife. Have a good day!
 
12:39 AM
If oyu want to learn C++ but from a more C view
check C++ without fear
It has alot of talk about C functions rather than STL
 
I'm reading "Accelerated C++", very good book.
2
 
can be a fast and good startup
 
Cheers, have to run now... have a good day.
 
1:13 AM
good evening lounge :)
 
 
1 hour later…
2:19 AM
Is this guy really advocating memory leaks?
0
A: In C++, why should `new` be used as little as possible?

jaybnyIt really depends on the program you are writing. For the systems that I write, allocating on the stack is impractical and deleting your heap allocations is unnecessary. I write very complex Object Oriented code, that requires collections of objects, multiple threads, and interprocess communica...

 
Or you could just use smart pointers and not worry about who owns your pointers, without leaking like a menstruating fire hose. — Etienne de Martel 3 mins ago
4
 
2:49 AM
Best answer ever!
 
 
2 hours later…
4:24 AM
@EtiennedeMartel Smart pointers don't rid you of thinking about ownership.
 
@StackedCrooked Indeed, but they simplify the whole thing quite a bit.
 
Yeah.
 
@EtiennedeMartel Right. They don't rid you of thinking about ownership -- they just make it a lot easier to enforce the ownership you decided you want.
 
You guys are both right. I'm gonna get some sleep.
 
Wussy.
 
4:35 AM
G'night.
 
(By the way, the part about the fire hose was blatantly ripped off from a Zero Punctuation episode)
 
Alright, gnight.
 
Small parting tidbit: the editor of the C++ standard (Pete Becker) just joined SO a couple days ago.
 
Is he joining the rep game? :)
 
@StackedCrooked I'd say it's a bit early to guess on that one. I believe his rep is currently in the ~150 range, but that doesn't really mean much. OTOH, like me, he's spent years answering lots of questions on Usenet.
 
5:04 AM
Does this mean people are abandoning Usenet?
 
5:23 AM
@StackedCrooked Undoubtedly -- but that's normal. People have come and gone for years. I do think in the past few years, more have decided to leave than enter though. By the time I left, spam on the unmoderated newsgroups was getting pretty awful, and I'm pretty sure it's still getting worse.
 
You need virtual inheritance to emulate Java interface implementation. FTFY. — Cheers and hth. - Alf 2 mins ago
^ @StackedCrooked
 
@Cheersandhth.-Alf Ah, that's right.
 
@StackedCrooked Actually, Alf is probably in a better position than I am to comment on Usenet (especially recently) and number of participants/posts (especially on comp.lang.c++.moderated).
 
I used to go to comp.lang.c++.moderated for my C++ questions. But I switched to SO very soon after I discovered it.
 
5:46 AM
-1
Q: why does finding max height of a tree behave differently on different compilers?

brainydexterI have the following piece of code to find the max height of a tree. It works correctly on MS VS 2010 compiler, however, when I try to run the same on ideone or rextester.com, I get a different result: The code is hosted here. It is a live session, so I'll be able to see the changes anyone makes...

Close votes pls.
 
6:40 AM
@StackedCrooked Smart ptr mean you don't make stupid mistake, forgetting some delete in some function exit path.
It is not mean you have a sane design.
Or that you even have a design at all.
Using smart ptr, you do less small stupid mistakes, but you can steal make huge design mistakes.
Smart ptr let you do two things very easily:
- randomly throw smart ptr on your code base (to fix leaks)
- randomly throw weak references on your code base (to fix cycles)
Or, you can have a proper design, and use smart ptr to express that design.
 
I'm installing the Azure SDK on MSVS 2010. Will my "totally legit" copy of MSVS still work afterwards?
 
7:12 AM
@Cheersandhth.-Alf "methinks you picked that up somewhere without really understanding what it's about here" Methink you have no idea what you are talking about and made and abusive comment I am flagging. — curiousguy 2 mins ago
^ In a way he has a point, but really, trying to remove a comment explaining what's wrong with his answer. Jeez.
I mean, he could just fix it instead.
 
7:28 AM
morning all
 
morning
I see I'm not the only one who comes late to work... ok. You are 1h behind.
 
sbi
@thecoshman Actually, babies often sleep as if they wouldn't be on this world. (You can carry them by their ankles when they are that deep asleep.) Usually it's only the first few months where they still have to find a rhythm of waking and sleeping where you have major problems catching enough sleep for yourself.
@BartekBanachewicz It's 9:45 here and I have yet to leave the house to go to work.
 
7:43 AM
@sbi So you're even better ^^
 
sbi
@BartekBanachewicz I wouldn't exactly call this "better".
I have to be at work by 11am, and it takes me about an hour to get there, so I should leave soon.
 
Well' I just have to sit here for 8 hrs, no matter when I start
 
sbi
@BartekBanachewicz You have fixed times to come and go? That's so 19th century.
 
@sbi That's SO. You haven't yet asked the question, you already got an answer xD
grammar is hard -.-
 
@sbi well, that 'quote' was not saying anything about how babies sleep, just that people who do not have babies tend to not know how they sleep.
I a word :(
 
7:47 AM
@sbi Nope, I just said no matter when I come and go, I just have to be productive for 8 hours. Or seem to be productive
 
sbi
@BartekBanachewicz Ah, I understand. That's luxurious for you, but it seems to totally ignore the fact that good software requires a lot of communication. If the guy who made that API I hack against is always only coming in when I leave, how can I ever effectively communicate with him? He could just as well be on the other side of the world.
@thecoshman That's a cheap attempt of weaseling. I'm not thrown off by that.
 
@sbi Well, given that office opens at, say, 6. am and closes at 8.pm, there's at least 2 hours of overlap, right?
 
sbi
@BartekBanachewicz Oh, preventing your programmers from staying late seems so strange to me, I never even considered it. :)
 
Corporate :P We have huge poster saying "Quality also means to avoid stress"
which, I guess, also involves not-overworking
 
sbi
@BartekBanachewicz Yeah, it does sound like reasonable policy. I wasn't opposed to it. I have, however, yet to see it for myself in the industry.
 
7:52 AM
I just hope they improve our coffee express high-availability. Right now it's the main stress factor ^^
 
@sbi ¬_¬ just chuckle at it will you
 
sbi
Well, did I mention I need to leave the house? Time to get dressed and pack my lunch.
See ya!
 
Xeo
@sbi IRTA "time to get depressed"
 
¬_¬ silly heap/stack question... if I allocate a std::string (for example) the string contents itself is on the heap, but is there a 'pointery thing' on the stack as well?
 
Xeo
8:00 AM
std::string s; // _first, _last, _end members on "stack", eventual content may be on heap or on stack with SSO
 
sbi
@Xeo Ha, "eventual" ist ein falscher Freund. You mean "probably".
 
@sbi I'd say just drop the word altogether
or may be 'actual'
@sbi and get to work already! :P
 
Xeo
@sbi "eventual content" doesn't seem wrong
 
@Xeo I don't think it works to well to be honest
 
Xeo
Hm, right.
 
8:13 AM
@Xeo eventual refers to an actual event, content itself cannot be eventual. The adding of content can be eventual (but likely even that is wrong here).
 
Xeo
If anyone here except @sbi knows German, dict.cc translates "eventual" as "möglich"/"etwaige"
Though "potential content" might work better after all
whatever
 
i think moeglich translates to "possible", but whatever ;p
 
yes
@StackedCrooked I used to just keep at it until I solved the problem, experiment more, read more books -- for my C++ questions. Then - last year - I discovered people 'use' the internet for that too. I was baffled
2
I use the internet as a reference, rarely for asking questions.
 
8:37 AM
@sehe Isn't asking questions looking for reference?
 
Hi
 
2
Q: Equivalent of Java interfaces in C++?

nickbrickmaster Possible Duplicate: How do you declare an interface in C++? Interface as in java in c++? I am a Java programmer learning C++, and I was wondering if there is something like Java interfaces in C++, i.e. classes that another class can implement/extend more than one of. Thanks. p.s. New...

 
What's an ITT human ?
 
^ This is embarassing for SO, in a way. The question has been closed as duplicate of a question that has been closed as duplicate of a just vaguely related question.
There is now no possibility of answering the question
And a complete answer has not been given (although both answers, through my commentary and fixups, hint strongly at the answer).
 
8:45 AM
I hate it when that happens.
 
Also consider the VC++'s '__interface' keyword. check MSDN. — Ken 4 hours ago
^ This is such a terrible idea.
 
Embrassment: that so many SO users interested in the C++ tag know so little that they're able to close two questions that way, preventing an answer from being given (most likely unaware that it hasn't even been given).
 
That's happened to be before, almost.
Mods are so quick to jump on duplicates without really thinking.
 
I've voted to reopen the first closed question about it,
0
Q: Interface as in java in c++?

Trall Possible Duplicate: How do you declare an interface in C++? Somebody asked me a qustion: "In C++ there are no interfaces like in java. But event then you could realize them in c++, how would you do that?" How? I would make a class with virtual methods. That would be look like an inter...

 
@BartekBanachewicz It's close. But not the same
 
8:49 AM
^ It needs 4 more reopen votes. <g>
@R.MartinhoFernandes I added a comment about it, just for completeness.
 
-1, it's abstract class, not interface. You can't own object via it's interface, i.e. interface can't have public destructor. (unless it's the IDestructible interface). — Abyx 1 min ago
 
I really don't get people who think it's OK to mark a question as a dupe of a question that is it self marked as dupe
 
@abyx you're at it again?
 
Is anyone here interested in robotics?
 
@Rocketmagnet I gather that @R.MartinhoFernandes is.
 
8:53 AM
struct IFoo
{
   virtual void some() = 0;
protected:
   ~IFoo() {}
}
 
I'm looking for people to follow my Robotics stackexchange proposal.
 
^ this is interface
 
hm, subtle
 
38
Robotics

Proposed Q&A site for professional robotic engineers, hobbyists, researchers and students.

Currently in definition.

 
but good point
i think your stance on it is too strong -- it's more a good guideline than a requirement of interface'ness -- but still a good point
 
Xeo
8:55 AM
Yeah, I don't think it warrants a downvote, just a remark
 
which means, i have some code to fix up...
 
@Cheersandhth.-Alf is he? or is he just a robot?
 
i think both?
 
@Abyx whose definition of interface is this? Java's?
 
@ecatmur mine.
but I also believe such interface is an OOP-style interface.
who cares about Java %)
 
9:01 AM
@Abyx I still don't know about the 'I' prefix. I prefer interfaces to be '*able', or some other sort of adjective that describes what a class with this interfaces does. for instance, rather then 'Iserialise' have 'Serialisable'
 
how about ISerializable?
 
@thecoshman and ReadableWriteable if it has read and write ? - I'd rather prefer something like IFile
 
@Cheersandhth.-Alf the 'I' just seems a bit silly to be, it reads better with out it. "I have a collection of Serialisable objects"
 
@Abyx well, I would probably go for two interfaces, one for Readable and t'other Writeable, but yeah
 
Xeo
9:04 AM
I have a new idea! has_serialize, has_read_write :)
 
it's a 'Readable' not an 'IRead'
@Xeo ¬_¬ no
 
IFile, AFile, CFile...
 
Xeo
@thecoshman why? :(
 
@Xeo because EVERY class would have to have 'has_serialize' in order for you to be able to call 'has_serialize()' on it, and templates :P
 
Xeo
@thecoshman I meant for the names
struct X : public virtual has_serialize{ std::string serialize() const{ ... } };
or can_serialize
 
9:07 AM
oh, as the interface name?
 
@Cheersandhth.-Alf lol, not much.
 
well, no. for the same reason I dislike the 'I' prefix
 
anyway any naming conventions are good if they are readable or documented somewhere
 
sbi
@Xeo Eventually, you'll learn the difference between the German "eventuell" and the English "eventual". OTOH, you probably won't.
 
@sbi what does 'eventuell' mean? besides angry red lines?
 
Xeo
9:08 AM
@sbi I suspect a mean intent behind the last sentence. :(
 
It's raining.
 
sbi
@thecoshman "probably", "maybe"
 
@sbi ah, so not a very good stand in for 'eventual'
 
You can't possibly do something eventually but not probably
 
0
Q: C++ [Byte Array] - [Byte Usage] - Simple

user1512695Please do NOT hate on me as I am VERY VERY new to C++.. I am currently trying to create an array of bytes in my C++ application... I m using the following code: #include "stdafx.h" const BYTE DMSN[693]={$55,$8B,$EC,$81,$C4,$A4,$FA,$FF,$FF,$89,$45,$FC,$E8,$1B,$02,$00,$00,$89,$85,$CC, $FD,$FF,$...

err... dollar signs are valid like that?
 
sbi
9:10 AM
@thecoshman Yeah. Now you may guess what "falscher Freund" stands for.
 
Xeo
no
They're not even part of the basic character set, IIRC
 
sbi
@Mysticial They might well be. Not in C++, though.
 
@Mysticial No.
 
sbi
@Xeo Oh, I just had to cram in some more or less meaningful usage of "probably", in order to make that play on words work. (Eventually you'll learn that you probably shouldn't put too much meaning into it.)
 
@Mysticial it looks like syntax from some scripting language
 
9:12 AM
namespace std { using namespace tr1; } - let's bring the light of C++11 into MSVC2008 !
 
@Cheersandhth.-Alf yeah, that's what I'm thinking too. Just not sure what language.
 
FTR doxygen is still running. It's been 24 hours.
 
sbi
@Abyx You're not allowed to do that. But I understand that that's half the fun in it.
 
@Mysticial lol, $ from pascal
 
@kbok Eventually usually implies some inevitability.
 
9:14 AM
bleh, I don't know any pascal
 
@sbi are you saying that 'enetuell does not mean eventual'
 
sbi
@thecoshman I thought we had already established that?
 
Especially since you wrote it wrong.
 
@sbi ¬_¬ in the bit you linked to as 'falscher Freund'... though I guesss Freund is some sort of name or place?
 
@thecoshman It means "friend".
 
9:16 AM
lol
 
sbi
@thecoshman Have you ever learned, or attempted to learn, a foreign language? If so, you might have encountered the phrase.
 
really? is it normal for Germans to capitalise it like that?
 
Nouns in German are always like that.
 
sbi
@thecoshman All nouns are capitalized in German.
 
@sbi There was a vague attempt at teaching me Spanish school
@sbi huh... maybe that's why it looks 'angry'
 
sbi
9:17 AM
@thecoshman Ah, without knowing much about Spanish, I venture a guess that it would be a good candidate to introduce the concept of a "false friend" to you — language-wise, mind you.
 
A "false friend" is a bastard who stabs you in the back.
 
sbi
@kbok ...language-wise, mind you!
 
huh, never heard that term before
 
@sbi Not just.
 
A "false friend" is a bastard who stabs you in the back, language-wise.
That's very awkward :p
 
sbi
9:21 AM
@thecoshman It refers to a word that sounds very similar to one in your own language and obviously share the same etymological rule, but means something else than the word in your language.
 
@sbi confused me did that :(
 
@thecoshman What is your native language ?
 
@kbok oh christ, am I really that bad? English
 
sbi
@thecoshman I think what native English speakers stumble over when reading German is three things: An orthography that might look archaic (e.g., umlauts, "k" instead of "c"), the regular stacking of consonants for certain sounds ("sch", "tz"), and the use of Western Germanic words ("Schwein", "will") rather than Northern Germanic ones ("pig", "want").
@kbok His is Engrish. :) <== See, I even added a smiley, so you know I'm just making fun of him.
 
@thecoshman No, but some non-native speakers are very good so you never know
 
9:25 AM
@sbi 'Sch' said like 'School'?
 
I feel like the Harry Potter books would have played out a lot differently if these people knew what guns were.
 
tz how ever, sounds like 'tits'
 
Now being Polish, it's even funnier to speak German ;p
 
sbi
@thecoshman Yes. It's pronounced "sh", however. ("Schule", pronounced "shool-e", means "school" in German.)
 
I personally had the most problems with the soft "Ich" and words like "Kirche"
 
sbi
9:28 AM
@thecoshman In German, doubled consonants mean that the vowel in front of them is meant to be short. Some consonants, however, are changed when doubled: "k" ==> "ck" (you have that as well), "z" ==> "tz". (There might be others I can't think of right now.)
 
@sbi does German share the Irish trait in that the more modern words are just the English word with 'e' tacked on. Ramp -> Rampaí
 
sbi
@BartekBanachewicz But that's mostly because you stack consonants even higher than we do, to cram your 1347 sibilant sound into the 26+ letters of the Roman alphabet.
 
@sbi Chrząszcz ;) unspeakable by German people since ever
 
sbi
@BartekBanachewicz Yeah, "ch" after "i" and "e" is something I have yet to hear in a foreign language.
@BartekBanachewicz Now that looks like your cat's been on the keyboard.
 
That's an ogonek!
 
9:32 AM
@sbi It means "Beetle". It's actually a part of quite famous Polish poem
 
@sbi Greek has it with χ.
 
sbi
@BartekBanachewicz The problem is that I don't even get far enough to mind proper pronunciation. The first problem I have is to know what sound "chrz" and "szcz" amounts to. (I have a hunch, but it's a weak one.)
 
Chrząszcz brzmi w trzcinie w Sczebrzeszynie
 
sbi
@R.MartinhoFernandes That, I think, is "ch" as pronounced after "a", "o", and "u".
 
@sbi When after "a", "o", and "u". It has the same rules as German when after "i" and "e".
I believe I told you this before.
 
9:34 AM
@sbi "sz" is quite similiar to "sh", same with "ch". So it would be like "shch", with virtually no pause in between. You have to accentuate the change, but still, even natives can trip over it.
 
sbi
@R.MartinhoFernandes Ah, I didn't know that. Nice. I can now just point anyone to Greek, when they ask how to pronounce the German "ch". They'll be none the wiser, but I look well-educated.
Oh, meeting time. Later.
 
What exactly would the difference between a normal 42 and a const 42 be? — FredOverflow 1 min ago
 
One is green, the other is purple.
 
9:44 AM
@Abyx Shouldn't the destructor be virtual as well?
@MohamedAhmedNabil "C++ without fear"? Isn't that the book with void main() on the cover? :)
 
Is void main not allowed?
 
@StackedCrooked I think it's undefined behavior.
 
@R.MartinhoFernandes referee? :)
 
Erm, stupid OP is trying to tell me I don't know SFINAE.
 
If you see a cartoon mascot on a C++ book's cover, run for the hills.
 
9:57 AM
21
Q: What is the proper declaration of main?

FredOverflowWhat is the proper signature of the main function in C++? What is the correct return type, and what does it mean to return a value from main? What are the allowed parameter types, and what are their meanings? Is this system-specific? Have those rules changed over time? What happens if I violate...

> The return type of main must be int.
> I've never seen an IDE that completely answers all those questions - does yours tell you about the history of the language? If so, please share!
lol
 
man, I read the most terrible of lies yesterday
 

« first day (668 days earlier)      last day (4280 days later) »