« first day (839 days earlier)      last day (4108 days later) » 

5:02 AM
For some reason, enums always seem to bring out the shittiest questions.
 
Wow, guess what I found in Visual Assist X's refactoring features page.
 
lol nice, but I usually write my class interface first. Can it be done the other way around?
 
@Borgleader, Of course, but that's not the point.
It's a vector of references.
 
Oh... I thought your point was about the feature
 
You say infinite loops are bad?
2
 
5:11 AM
I hate recursive clips. They mess with my mind.
 
As for a vector of references you kinda have to if you're storing derived objects
 
The problem is that you can't really do anything at all with the vector since references can't rebind. Pointers are the usual option for that. I think the standard explicitly disallows containers of references, but even with std::reference_wrapper, it's still pretty useless to work with.
 
You are correct, I get a "pointer to reference is illegal" compilation error
 
5:26 AM
@Chris you can store vector<Student&> ?
 
@billz yes
oh wait hold on
brain read that wrong
 
@billz, You can use a std::vector<std::reference_wrapper<Student>>, but it kills the point of the vector.
Plus, since you can't add on, you have to know it all at compile-time.
 
cool, thanks
 
reference_wrapper doesn't store a reference
It's both copyable and assignable
 
Oh, I didn't notice it was.
I guess it doesn't defeat the point then.
 
5:31 AM
It wouldn't make much sense otherwise
 
Yeah, I was wondering. I never use it. I just opt for smart pointers instead.
Does it work just as well for polymorphism then?
 
Probably
It's not really a general-use thing
 
0
Q: Why don't I get a runtime error when I access an out-of bounds element of an array?

A.06In this code below I try to access the '-1'th element of an array, I don't get any runtime error. #include <stdio.h> int A[10] = {0}; int main(){ A[-1] += 12; printf("%d",A[-1]); return 0; } When I run the code, it outputs 12 that means it is adding 12 to the non-existen...

 
Someone doesn't quite understand what UB means, even when it has been pointed out to said OP.
 
5:42 AM
It's one of those concepts that you either get it or you don't.
 
@Insilico, I'm used to it. I repeat myself an average of three to four times per question.
 
Most people get it after a while.
 
I mean on the "why doesn't it crash" questions at least.
 
Where's that FAQ question that talked about UB?
 
I always get amazed at the lack of UB in C# and Java. It's such a hard concept for me that there's no UB. I'm always wondering what exactly it does.
 
5:44 AM
@chris Well, technically, if you have race conditions, then bad things can still happen.
 
@chris The VM and/or JIT enforces certain things like out-of-bounds problems.
 
I don't think it's possible to completely define the behavior when it involves race conditions.
Basically, not even the hardware has well defined behavior for race conditions.
So you can't possibly to expect any software layer on top to cover it up.
 
Of course, that comes at a cost, and C++ follows the "you-pay-for-what-you-get" philosophy to a certain extreme.
If you want bounds checking, use a container that does it e.g. std::vector's at() function.
 
I'm thinking more of i = ++i + i - i++;
 
@chris The language standards for C# and Java I believe does say something that makes that statement have defined behavior.
 
5:49 AM
3
Q: Solving a signal modulation using equations

tinkerI am trying to solve a problem that involves solving of linear equations for signal processing. My task however does not allow me to use any third party library other from language core features of C/C++ or Java. From the problem scenario, I know that its not a simple three dimensional linear eq...

How does this have upvotes?
He literally copy pasted a challenge question and asked "Can anyone help me do it?"
 
@Insilico, Yeah, the problem is that I look at it and wonder what exactly they defined it to do :p
 
Ok, so Java has undefined behavior as well
11
Q: What are the common undefined behaviours that Java Programmers should know about

hhafezThe same as this question but for java Update Based on the comments and responses of a few people, Its clear that Java has very little undefined behaviour. So I'd like to ask as well what behaviour is not obvious. Please when answering make the distinction between the two :)

I figured.
It's not possible to completely avoid undefined behavior in any language with threads.
Unless you pay with performance.
 
Using the C++ termonology, none of these are "undefined", they are "implementation defined", which is very different. — Mooing Duck Oct 26 '12 at 23:14
 
@Insilico Well, I don't think Java even has an "implementation defined" for thread race conditions.
You can't even guarantee sequential consistency even if you tried.
 
@Mysticial One could argue that it's dependent on how the OS schedules threads.
 
5:52 AM
@Insilico It's even worse than that.
It's at the hardware level.
 
@Mysticial I know, I was just playing devil's advocate. :-)
 
@Mysticial Java originally tried to eliminate all UB -- everything should be either defined and 100% portable, or else illegal. That changed pretty quickly when the saw the (lack of) performance.
 
On x86 for example, if you simultaneously write a 64-bit value to the same location from two different cores, you might end up with half of one and half of the other depending on how the microops got ordered with the cache coherence.
@JerryCoffin Yeah, I heard something like that.
 
0
Q: Is it possible, in C++, to do some funky stuff when calling my function to return different types depending on my program's needs?

LeonardoConsider the useful code by Zaita posted at cplusplus.com, in particular the part which gets numbers safely, modified to be a function in my case: int get_number() { /** * cplusplus.com/forum/articles/6046 * gets number from input stream **/ string input = ""; int number = ...

 
@Mysticial I should add that this doesn't stop them from trying to imply that it has no UB, with things like "From the very beginning, Java was designed to eliminate all undefined behavior." Technically true (it was at the beginning) but implies a falsehood (that it isn't and never has been present).
 
5:56 AM
templates?!
 
Someone needs to dust off their C++ book.
Or buy a more modern one than how long ago did C++ not have them?
 
weren't templates added in C++98?
 
@chris I thought C++ had templates since the language was invented in some form.
 
Well, not since it was invented, I think since it was standardised.
 
Yeah, sometime between C with Classes and C++ came templates.
 
6:01 AM
I prefer templates to all generics I've seen.
 
@Insilico Not since the very beginning, though pretty close. The first experimental implementation was in 1988, and a proposal for them was accepted by the standard committee in 1990. So yes, they were present (and no longer even very new) when the first standard was released.
 
@JerryCoffin Yeah, it was definitely sometime early in the language's history. Unlike Java where some bastardized version of templates didn't come until version 6 or whatever it was.
 
and C# generics too.
 
I don't really know any generics past C++ and C#, so I can't weigh in.
I do remember some discussion about a language that uses square brackets instead of angle brackets.
 
I think that's D's variadic templates.
 
6:06 AM
@Rapptz It's pretty clear that neither Java nor C# even attempted to solve the same scope of problems as C++ templates. They only wanted to support collections of T, nothing more (and did exactly that and virtually nothing more).
@chris Quite possibly a better choice. The angle brackets came from Ada, where they didn't cause a problem, but syntactically they're much harder to integrate with C++.
 
6:32 AM
1
A: Automatically generate values for #define using vi[m]

Daniel FleischmanGo ahead and put a "1" after the #define ONE (where it should be at the final state). Go to the beginning of that line (with the cursor over the #) and press the following keys (where C-a means "ctrl+a"): qq3why$j$pC-a^q48@q Now the explanation: qq = record a macro called "q" 3w = move three ...

 
@Rapptz I hope said OP isn't creating macros that are actually called #define ONE 1, etc.
 
pretty sure he is.
kind of sad/weird really
 
Thanks for your answer @billz but I have to stick to macros here! — Sangeeth Saravanaraj 23 mins ago
What's with people tagging questions as but can't use C++ features for some reason?
 
@Insilico Why the hell would the OP do that?
 
enum is hardly a C++ thing :P
 
6:35 AM
@Rapptz Oh yeah I forget. :-P
But that makes the OP's strange requirement even dumber than it already is.
 
C++ does have some cool things with enums though.
 
@Mysticial The hell I know. I don't understand why programmers just in general have some weird aversion to C and C++ features.
 
It's like asking someone to give you a sword. So you can stab yourself. Over and over again...
 
I don't remember what went through my head when I wrote this
Let alone how it works..
 
@Rapptz, It works by adding the character values and comparing against preknown totals :p
 
6:42 AM
oh that's right, ascii
I was staring at it for a while
I should probably comment my code more..
oh it only works for 1-10
 
What even?
 
^^ He actually had it less wrong before the edit.
His original answer was something like if (number & 0x55555555) return 1;
 
6:57 AM
@Aniket: yes, this is why your solution does not work. — Paul R 28 secs ago
lol
 
lol
 
I don't actively browse the c tag.. maybe I should for fun.
 
I do.
I may not know C, but at least I try to pretend like I do.
 
these programs are worse than the C++ tag.
 
Honestly, browsing the C++ tag was one of the biggest factors of what I know about C++ now.
Another being taking a first-year high school class, and a third being finishing reading the book we did the first 8 chapters of.
being finishing reading. That doesn't sound right.
 
7:04 AM
double input = atof(argv[1]);
float input2;
input2 = input;
input2 = floor(input2 * 100) / 100;
 
lol
 
0
Q: Not sure what's causing this error, Moneyconverter program in C

user2031589So far, this can read simpler decimal numbers like $10.00, $220.50, $14.25. But when it becomes numbers like $12.76, $320.84, $47.53, then it wouldn't even run. I'm wondering what is causing it and how I can fix it. This is the .h file #define TWENTY_BILL 20.00 #define TEN_BILL 10.00 #define ...

Is it me or does he comment way too much?
 
I used to do something like that (though not nearly that bad) when sharing my code, whereas I usually had none when writing it.
 
@Rapptz It's definitely a lot. But I wouldn't say it's too much though.
 
Depending on what it was, anyway. winapi and what not aren't apparent to most people.
 
7:08 AM
@Mysticial Really?
 
@Rapptz For code like that, it's okay to have a lot of comments.
But for "dense" straight-line code, then it can get in the way.
 
Why? It's.. kind of self-documenting. It's obvious to an extent what everything does.
 
It's too obvious as to what it's doing to have so many comments imo.
 
@Jack Real programmers index from zero. :P — Mysticial 6 mins ago
 
Maybe one for the code sample Rapptz posted and one or two briefly explaining the general idea instead of one long one per if case.
 
7:10 AM
yeah -- he didn't add a comment to the only thing that doesn't make sense.
funny imo at least a very well descriptive comment.
 
@chris Yeah I saw but what is the point?
 
More comments than code lol.
 
Why transfer it?
 
I honestly don't know.
Just a novice act I guess.
I still can't get this game's ending out of my mind.
All that was left was to reunite with the person you've been searching for all game.
 
7:14 AM
That's impossible.
 
And suddenly the main character dies and all of your game-long effort gets reversed.
 
@tom_mai78101 What is?
 
@Rapptz this:
>All that was left was to reunite with the person you've been searching for all game.
 
money converter program works already
sent him an ideone of it <- edit
 
I tried compiling it and replaced argv with a scanf but it infinitely loops.
 
7:15 AM
How? If they just brought that character out and made everyone happy, it would have worked as a pretty good ending.
 
I forgot how to quote your quotes. /
 
@tom_mai78101, arrow->permalink
 
Yes, thanks.
 
@doug65536 huh interesting. It works with your input but on my input (12.74) is infinitely loops.
 
On a unrelated topic compared to all of you, I can't believe I have to wait for quite while for copying/pasting files to finish.
 
7:17 AM
the question says it doesnt work right? maybe not his definition of "works" :)
 
Once to estimate the time and once to actually copy. That's the Windows way.
Anyway, I told the person to just use integers for the number of cents.
Seems more logical than all of the floating-point nonsense you have to deal with and worry about.
 
1 kB file, copy/pasting in the same destination on a broken USB drive = estimated time completion: 1 hour 47 minutes
Yay for tech support gore.
 
@Rapptz interesting (mine loops with "invalid change" too). I suppose he wants us to unit test it for him? lol
 
Estimation time is rising. It's now 2 hours 13 minutes.
 
I remember doing a similar problem a couple days ago (lol)
#include <iostream>

int main() {
    std::cout << "How much money do you have?";
    float fChange;
    std::cin >> fChange;
    int change = fChange * 100;
    int quarters = change/25;
    int dimes = (change %= 25)/10;
    int nickels = (change %= 10)/5;
    int pennies = (change %= 5);
    if(quarters) std::cout << "Quarters: " << quarters;
    if(dimes) std::cout << "\nDimes: " << dimes;
    if(nickels) std::cout << "\nNickels: " << nickels;
    if(pennies) std::cout << "\nPennies: " << pennies;
 
7:22 AM
Couldn't your int assignment cause it to be one cent less?
 
lmao its a floating point roundoff error?
 
@chris Hm, it worked with all the challenge inputs.
 
0.999999999... is left?
 
I just got serially upoted. I hope it doesn't get reversed...
 
7:23 AM
That's why I don't like floating-point numbers. I never know whether I should actually take extra precautions or not.
That wouldn't take much, though, just a std::round.
 
@Mysticial I'm pretty sure by th time you reach above 600, you'll start to see your first negative reps.
 
@tom_mai78101 600 what?
 
600 rep!
 
@Mysticial 600 reps
 
lol
 
7:24 AM
I think I got my first downvote way before I reached 600.
 
I got mine, twice in a row. Currently -4 this week.
 
It was me.
I admit it.
 
You. YOU.
Upvote me, and I will forgive you.
 
it's okay.
Someone unaccepted my answer :(
 
It happens. :/
 
7:26 AM
yesterday was the first day I actually got more rep than the rep cap and had wasted upvotes.
 
@Rapptz Woah, that's a lot of over the cap votes.
 
Wished I'm on a roll.
 
@Mysticial :D
 
The only time I repcap now is when I hit a decent answer.
By "decent" I mean 10 upvotes + the usual passive rep that I get.
 
We'll, you nailed that.
I'll hammer that down for you.
We can plank around for some more upvotes.
 
7:29 AM
Maybe on extremely busy weekdays, I'll get a passive repcap. But those are rare.
 
Prying on those passive reps.
 
I cannot use functions lol
 
@tom_mai78101 Nah... I've just been extremely lucky a few times.
 
I think that came out wrong, seeing as how they do use functions.
 
@chris void main()?
 
Yeah, that's pretty hackish...
 
I think they mean they can't use the cstdlib file functions.
 
@chris Add that into the question. And state more info.
Oh, that's not your question? I'm lost in context again.
 
chris wouldn't ask a question like that. He trolls them instead.
Albeit not as well as some of the regulars here.
 
@Mysticial, My graph feels so empty compared to yours.
 
7:36 AM
You need to look at my graph between April and July.
Before April, I was an active repwhore.
Then I stopped.
And then we all know what happened at the end of June.
 
I'm just too <insert word that I forget here> to post really helpful answers/comments to everything. It's easier to touch on the right answer without explaining anything (which is sometimes ok if they Google what you post) or laugh about some bad code.
 
@chris And that's why @Luchian hates your ass. :)
 
@Mysticial, Wait, you got 345 rep in one day?
 
Anyone here knows the currency, NTD?
 
@chris Association bonus.
I've only had 2 or 3 real >300 days.
All during my first few months.
 
7:39 AM
@tom_mai78101, New Taiwan Dollar apparently.
 
I haven't had a 245 day since March.
 
So, I've heard that the exchange rate of NTD <-> USD is getting better. Does that mean USD is getting worse?
 
@Mysticial, I could work out more if that's the only part of me he hates.
 
@chris lol
Aww dammit. Luchian finally overtook me in C++. And now I'm down to 5th. :(
Kinda wished the tag wasn't removed from the Pi question.
 
lol I never saw this one.
Why don't you just divide by pi and check if the result is 1? (just kidding) — Mehrdad Jan 18 at 4:26
 
7:49 AM
1
Q: printing odd and even number printing alternately using threads in C++

user258367Odd even number printing using thread I came across this question and wanted to discuss solution in C++ . What I can think of using 2 binary semaphores odd and even semaphore. even semaphore initialized to 1 and odd initialized to 0. **T1 thread function** funOdd() { wait(even) pri...

^^ Oh god... that title sounds like a disaster is gonna happen.
 
The most instantaneous close I've ever seen: stackoverflow.com/questions/14641849/…
 
3 minutes... meh... I've seen < 1 min. closures by normal users and 10 second closures by mods.
"man-made rules"? Not being rude, but C++ is made by... yeah. Maybe you mean implementation-specific rules. — Mark Garcia 3 mins ago
^^ ahahahahahaha
 
8:06 AM
Am I missing something here? Are we enjoying how bad questions are asked by others inexperienced in using a general language to program?
It wasn't supposed to be like this a few weeks ago. :/
 
http://stackoverflow.com/questions/14642015/whats-the-most-efficient-container-for-insertion-from-the-back-and-removal-from#comment20456291_14642015
LOL!
 
Guys. I'm thinking of posting this over at that isocpp thread:
 
WOW
 
I'd like this post removed in absense of any credentials.

This has all the hallmarks of a scam, for me. At best it is an elaborate joke.

If anything it is advertising. Do we need to allow advertising to spoil the isocpp forums?
@R.Martinho @Xeo @sbi Can anyone wise tell me why I shoule not post that there? Is there some kind of unspoken troll silent treatment method I don't know about?
Mmm. I guess, I'm really just looking for that 'flag as spam' button... Lemme look
@MarkGarcia Awesome
@chris Gah! The delusion! You merely think 'normal' observations don't mess with your mind. All sensory observation is based on your brain telling you pretty lies
 
@tom_mai78101, It's good to lay back and have a good laugh. Everyone writes terrible code at some point. I'm never going to live down that idea of timing out input.
 
8:17 AM
@chris I meant laughing at bad questions, not codes.
 
Plus I have an extensive collection of old code, tons of which I would look back to now and hate myself for.
 
Or maybe I have worded that wrong. :(
 
Oh, the bad questions are usually pretty funny. It just takes more time to realize it yourself.
Some of them completely lack common sense, though.
 
@sehe Watched it again. But more awesomeness had come upon me: Firefox's icon's animated!
 
From my experiences, reading a really bad question means most of the time, they lacked programming experiences. Lacking those skills, may inadvertedly affect lack of common sense.
 
8:19 AM
@MarkGarcia Wut. Another reason to stay away of Firefox?
@tom_mai78101 causality reversal?
 
@sehe So, you're implying that you're siding with Chrome?
 
@sehe I just think it's cool. I could see the GIF without opening the tab!
 
@tom_mai78101 NO?!
 
@sehe Inverse correlation, sorry.
 
@Mysticial I don't hate him. I laid off the repwhoring recently as well :)
 
8:21 AM
@MarkGarcia Oh, so it's not Firefox's icon. It's the thumbnail. Yeah, that's nifty. Especially for youtube or similar
 
Not completely, but nowhere near couple of months ago
 
@sehe I just can't understand sarcasm. :( Sorry.
The browser wars are getting on me.
 
@tom_mai78101 It can be both ways, it's not an inverse correlation. I'm just pointing out that some people aren't dumb because they don't have experience, but they'll not get experience because they are... well you get it
 
@tom_mai78101 Late.
 
@tom_mai78101 Opera FTW. I don't particularly like FF
 
8:22 AM
@LuchianGrigore, You don't hate me? Anyone else want to fill the void here?
 
@chris Happy to oblige
 
@sehe Heard they are forfeitting their own library for WebGL.
 
@LuchianGrigore Wut! This is the end of SO as we know it!
 
May I offer you some more half-brained C++ schemes?
 
@tom_mai78101 That might be good. I'm not qualified to judge the effects
 
8:24 AM
@chris You sound disappointed. :)
 
Hmm, I can't help but wonder what it would be like trying to learn C++ with an instructor that forced you to use bad examples of operator overloading and such and convinced you it was normal.
 
@sehe Me neither. I do suppose we are about to get everything standardized, so that the most obvious changes would become the de facto standard of Web 3.0
 
Like my last fun one thinking up: std::cout << (2,5_pnt).y; //5
 
@chris That would be demotivating you to be a programmer.
 
@chris Once you have that thought, you wouldn't be weak enough to be convinced.
 
8:27 AM
Oh, you need a std::pair<int, int>? They have a suffix for it now: auto pair = 2.9p;
I think I would die if I had to maintain code like that.
Darn, all I accomplished this exam week was reversing my sleep cycle again.
 
@chris "I have jet lag this week." is a nice excuse.
Everyone will envy you since you'd made everyone think you have a vacation.
 
Well, I also managed to turn my brain to mush, so I can't focus on what I need to do sometime.
 
 
@chris Pluck some flower petals, toss a coin into a fountain, go outside, etc. I can think of all the things, if it wasn't for the rain outside.
 
No enum?! Stop using ancient <strike>DevC++</strike> oh <strike>Borland C++ 3.1</strike> sh*t <strike>TinyCC</strike> wait... `The original K&R dialect of the C programming language did not have enumerated types, but they were added in the ANSI standard for C, which became C89` - You don't have an excuse, really.sehe 1 min ago
@tom_mai78101 take a rain bath
 
8:41 AM
good morning gals :)
 
morning fellas.
 
Good Eeveening.
 
Incidentally, Jonathan has written a quite awesome response to my iostreams debacle and it’s currently running around dressed with only two upvotes … maybe you guys could help this poor, naked answer
2
A: Implement reading from stream via copy

Jonathan WakelyYou don't want to clear(eofbit) because the failbit should stay set if reading failed due to reaching EOF. Otherwise if you just leave eofbit set without failbit then a loop such as while (in >> s) will attempt another read after reaching EOF, and then that read will set failbit again. Exce...

 
Has anyone found the missing topic? Pokemon as reward.
 
Nope
It's still missing
 
8:47 AM
:(
 
silly me, ip4 can't have an octet 594 :P where ever did that 4 slip in
 
ouch :(
If you watch the software industry backwards, it starts with kids flailing; ends with old guys solving impossible problems by thinking hard.
 
More like: If you watch the software industry backwards, it starts with kids playing CoD, becoming circlejerks, and ruining innovation; ends with old guys solving impossible problems by thinking hard.
 
Xeo
@LucDanton Not really, no.
 

« first day (839 days earlier)      last day (4108 days later) »